Skip to content

Commit a90e48d

Browse files
committed
[FIX] estate: added reports
1 parent e8c6822 commit a90e48d

File tree

6 files changed

+239
-6
lines changed

6 files changed

+239
-6
lines changed

estate/__manifest__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
'data': [
66
'security/security.xml',
77
'security/ir.model.access.csv',
8+
"report/estate_property_templates.xml",
9+
"report/estate_property_offer_reports.xml",
810
'views/estate_property_views.xml',
911
'views/estate_property_type_views.xml',
1012
'views/estate_property_tag_views.xml',
11-
'views/inherited_model_view.xml',
13+
'views/res_users_view.xml',
1214
'views/estate_menu.xml',
1315
'data/estate_property_type.xml',
1416
],
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<record id="paperformat_lowmargin" model="report.paperformat">
4+
<field name="name">A4 low margin</field>
5+
<field name="default" eval="True" />
6+
<field name="format">A4</field>
7+
<field name="page_height">0</field>
8+
<field name="page_width">0</field>
9+
<field name="orientation">Portrait</field>
10+
<field name="margin_top">5</field>
11+
<field name="margin_bottom">5</field>
12+
<field name="margin_left">5</field>
13+
<field name="margin_right">5</field>
14+
<field name="header_line" eval="False" />
15+
<field name="header_spacing">0</field>
16+
<field name="dpi">80</field>
17+
</record>
18+
<record id="estate_property_offer_reports" model="ir.actions.report">
19+
<field name="name">Property Offers</field>
20+
<field name="model">estate.property</field>
21+
<field name="report_type">qweb-pdf</field>
22+
<field name="report_name">estate.report_estate_property_offers</field>
23+
<field name="report_file">estate.report_estate_property_offers</field>
24+
<field name="print_report_name">'%s - Property Offers' % (object.name)</field>
25+
<field name="paperformat_id" ref="estate.paperformat_lowmargin" />
26+
<field name="binding_model_id" ref="estate.model_estate_property" />
27+
<field name="binding_type">report</field>
28+
</record>
29+
30+
<record id="estate_property_salesman_report" model="ir.actions.report">
31+
<field name="name">Salesman Property</field>
32+
<field name="model">res.users</field>
33+
<field name="report_type">qweb-pdf</field>
34+
<field name="report_name">estate.report_estate_property_salesman</field>
35+
<field name="report_file">estate.report_estate_property_salesman</field>
36+
<field name="print_report_name">'%s - Property Offers' % (object.name)</field>
37+
<field name="paperformat_id" ref="estate.paperformat_lowmargin" />
38+
<field name="binding_model_id" ref="base.model_res_users" />
39+
<field name="binding_type">report</field>
40+
</record>
41+
</odoo>
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<odoo>
3+
<!-- Sub-template for the offers table -->
4+
<template id="report_estate_property_offers_table">
5+
<table class="table">
6+
<thead>
7+
<tr>
8+
<th>
9+
<strong>Price</strong>
10+
</th>
11+
<th>
12+
<strong>Partner</strong>
13+
</th>
14+
<th>
15+
<strong>Validity (days)</strong>
16+
</th>
17+
<th>
18+
<strong>Deadline</strong>
19+
</th>
20+
<th>
21+
<strong>Status</strong>
22+
</th>
23+
</tr>
24+
</thead>
25+
<tbody>
26+
<t t-set="offers" t-value="property.mapped('offer_ids')" />
27+
<tr t-foreach="offers" t-as="offer">
28+
<td>
29+
<span t-field="offer.price" />
30+
</td>
31+
<td>
32+
<span t-field="offer.partner_id" />
33+
</td>
34+
<td>
35+
<span t-field="offer.validity" />
36+
</td>
37+
<td>
38+
<span t-field="offer.date_deadline" />
39+
</td>
40+
<td>
41+
<span t-field="offer.status" />
42+
</td>
43+
</tr>
44+
</tbody>
45+
</table>
46+
</template>
47+
48+
<!-- Main template -->
49+
<template id="report_estate_property_offers">
50+
<t t-foreach="docs" t-as="property">
51+
<t t-call="web.html_container">
52+
<t t-call="web.external_layout">
53+
<div class="page">
54+
<div>
55+
<h2>
56+
<span t-field="property.company_id.name" />
57+
</h2>
58+
</div>
59+
<div>
60+
<span t-field="property.company_id.street" />
61+
</div>
62+
<div>
63+
<span t-field="property.company_id.city" />
64+
</div>
65+
<div>
66+
<span t-field="property.company_id.state_id.name" />
67+
</div>
68+
<div>
69+
<span t-field="property.company_id.country_id.name" />
70+
</div>
71+
<h1>
72+
<span t-field="property.name" />
73+
</h1>
74+
<div>
75+
<strong>Salesman: </strong>
76+
<span t-field="property.salesman_id" />
77+
</div>
78+
<div>
79+
<strong>Expected Price: </strong>
80+
<span t-field="property.expected_price" />
81+
</div>
82+
<div>
83+
<strong>Status: </strong>
84+
<span t-field="property.state" />
85+
</div>
86+
<div>
87+
<t t-if="property.state == 'sold'">
88+
<strong>!!! Invoice is already being created!!! </strong>
89+
</t>
90+
</div>
91+
<t t-if="property.offer_ids and len(property.offer_ids)>0">
92+
<t t-call="estate.report_estate_property_offers_table" />
93+
</t>
94+
<t t-else="">
95+
<h2>No offers available for this property.</h2>
96+
</t>
97+
</div>
98+
</t>
99+
</t>
100+
</t>
101+
</template>
102+
103+
<template id="report_estate_property_salesman">
104+
<t t-foreach="docs" t-as="user">
105+
<t t-call="web.html_container">
106+
<t t-call="web.external_layout">
107+
<div class="page">
108+
<h2>
109+
<strong>Salesman: </strong>
110+
<span t-field="user.name" />
111+
</h2>
112+
<t t-if="user.property_ids">
113+
<t t-foreach="user.property_ids" t-as="property">
114+
<div style="margin-bottom: 30px;">
115+
<h4>
116+
<span t-field="property.name" />
117+
</h4>
118+
<div>
119+
<strong>Expected Price: </strong>
120+
<span t-field="property.expected_price" />
121+
</div>
122+
<div>
123+
<strong>Status: </strong>
124+
<span t-field="property.state" />
125+
</div>
126+
<t t-if="property.offer_ids">
127+
<t t-call="estate.report_estate_property_offers_table" />
128+
</t>
129+
<t t-else="">
130+
<p>No offers available for this property.</p>
131+
</t>
132+
</div>
133+
</t>
134+
</t>
135+
<t t-else="">
136+
<h4>No properties available for this salesman.</h4>
137+
</t>
138+
</div>
139+
</t>
140+
</t>
141+
</t>
142+
</template>
143+
</odoo>

estate/views/estate_property_type_views.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@
3131
<field name = "arch" type="xml">
3232
<form>
3333
<sheet>
34-
<div class="oe_button_box" name="button_box">
34+
<div class="oe_button_box" name="button_box">
3535
<button name="%(action_property_offers)d"
3636
type="action"
3737
class="oe_stat_button"
3838
icon="fa-money">
3939
<field name="offer_count" widget="statinfo" string="Offers"/>
4040
</button>
41-
</div>
42-
<h1 class="mb32">
43-
<field name="name" class="mb16"/>
41+
</div>
42+
<h1 class="mb32">
43+
<field name="name" class="mb16"/>
4444
</h1>
4545
<notebook>
4646
<page string="Properties">

estate/views/estate_property_views.xml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<record id="estate_property_action" model="ir.actions.act_window">
44
<field name="name">Properties</field>
55
<field name="res_model">estate.property</field>
6-
<field name="view_mode">list,form</field>
6+
<field name="view_mode">list,form,kanban</field>
77
<field name="context">{'search_default_state': 1}</field>
88
</record>
99

@@ -28,6 +28,39 @@
2828
</field>
2929
</record>
3030

31+
<record id="estate_property_kanban" model="ir.ui.view">
32+
<field name="name">estate.property.kanban</field>
33+
<field name="model">estate.property</field>
34+
<field name="arch" type="xml">
35+
<kanban class="o_kanban_small_column" default_group_by="property_type_id" records_draggable="0">
36+
<field name="state" />
37+
<field name="property_type_id" />
38+
<templates>
39+
<t t-name="card">
40+
<div>
41+
<div style="font-weight: bold; font-size: 1.1em;">
42+
<field name="name" />
43+
</div>
44+
<div>
45+
<field name="property_tag_ids" widget="many2many_tags"
46+
options="{'color_field': 'color'}" />
47+
</div>
48+
<div>
49+
<span>Expected Price: <field name="expected_price" /></span>
50+
</div>
51+
<div t-if="record.state.raw_value == 'Offer Received'">
52+
<span>Best Price: <field name="best_offer" /></span>
53+
</div>
54+
<div t-if="record.state.raw_value == 'Offer Accepted'">
55+
<span>Selling Price: <field name="selling_price" /></span>
56+
</div>
57+
</div>
58+
</t>
59+
</templates>
60+
</kanban>
61+
</field>
62+
</record>
63+
3164
<record id="estate_property_form" model="ir.ui.view">
3265
<field name="name">estate.property.form</field>
3366
<field name="model">estate.property</field>
@@ -39,6 +72,13 @@
3972
<field name='state' widget="statusbar" statusbar_visible="new,Offer Received,Offer Accepted,sold"/>
4073
</header>
4174
<sheet>
75+
<div class="oe_button_box" name="button_box">
76+
<button name="%(estate.estate_property_offer_reports)d"
77+
class="oe_stat_button"
78+
type="action"
79+
icon="fa-print"
80+
string="Print" />
81+
</div>
4282
<h1 class="mb32">
4383
<field name="name" class="mb16"/>
4484
</h1>

estate/views/inherited_model_view.xml renamed to estate/views/res_users_view.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
<field name="model">res.users</field>
66
<field name="inherit_id" ref="base.view_users_form"/>
77
<field name="arch" type="xml">
8+
<div class="oe_button_box" name="button_box">
9+
<button name="%(estate.estate_property_salesman_report)d"
10+
class="oe_stat_button"
11+
type="action"
12+
icon="fa-print"
13+
string="Print" />
14+
</div>
815
<notebook position="inside">
916
<page string="Properties">
1017
<field name="property_ids">

0 commit comments

Comments
 (0)