Skip to content

Commit b413bdd

Browse files
committed
[IMP] estate: reports and report template create and updated demo data
Created reports templates and reports actions for estate and estate_account module. It was very challenging. but get and idea after going through docs and chatgpt. Made report actions, sub - template and templates, combined and create pdf report for property and for for salesman. also included invoice status using inherited report concept. updated demo data as well to make report making simpler for next database. updated some filter rules in estate.
1 parent 3ef4f7e commit b413bdd

15 files changed

+241
-18
lines changed

estate/__manifest__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,30 @@
77
part of technical training
88
""",
99
"data": [
10+
# reports
11+
"report/paperformat.xml",
12+
"report/company_details_templates.xml",
13+
"report/estate_property_offers_templates.xml",
14+
"report/res_users_reports.xml",
15+
"report/res_users_templates.xml",
16+
"report/estate_property_reports.xml",
17+
"report/estate_property_templates.xml",
18+
# views
1019
"views/actions_menu_and_button.xml",
1120
"views/menu_views.xml",
1221
"views/estate_property_views.xml",
1322
"views/estate_property_type_views.xml",
1423
"views/estate_property_tag_views.xml",
1524
"views/estate_property_offer_views.xml",
1625
"views/res_users_views.xml",
26+
# security
1727
"security/ir.model.access.csv",
1828
],
1929
"demo": [
2030
"demo/estate.property.types.csv",
2131
"demo/estate.property.tags.csv",
2232
"demo/estate_property_demo.xml",
23-
"demo/estate_property_offers_demo.xml"
33+
"demo/estate_property_offers_demo.xml",
2434
],
2535
"application": True,
2636
"installable": True,

estate/demo/estate_property_demo.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<field name="garage">True</field>
1515
<field name="garden">True</field>
1616
<field name="garden_area">100000</field>
17+
<field name="user_id" ref="base.user_admin" />
1718
<field name="garden_orientation">south</field>
1819
<field name="property_type_id" ref="estate_property_type_villa" />
1920
</record>
@@ -32,6 +33,7 @@
3233
<field name="garage">False</field>
3334
<field name="garden">False</field>
3435
<field name="garden_area">0</field>
36+
<field name="user_id" ref="base.user_admin" />
3537
<field name="garden_orientation" />
3638
<field name="property_type_id" ref="estate_property_type_apartment" />
3739
</record>
@@ -47,6 +49,7 @@
4749
<field name="bedrooms">15</field>
4850
<field name="living_area">10000</field>
4951
<field name="facades">4</field>
52+
<field name="user_id" ref="base.user_admin" />
5053
<field name="garage">False</field>
5154
<field name="garden">False</field>
5255
<field name="garden_area">0</field>
@@ -86,6 +89,7 @@
8689
<field name="bedrooms">5</field>
8790
<field name="living_area">350</field>
8891
<field name="facades">3</field>
92+
<field name="user_id" ref="base.user_admin" />
8993
<field name="garage">True</field>
9094
<field name="garden">True</field>
9195
<field name="garden_area">500</field>
@@ -105,6 +109,7 @@
105109
<field name="selling_price">0.00</field>
106110
<field name="bedrooms">0</field>
107111
<field name="living_area">1000</field>
112+
<field name="user_id" ref="base.user_admin" />
108113
<field name="facades">2</field>
109114
<field name="garage">False</field>
110115
<field name="garden">False</field>
@@ -126,6 +131,7 @@
126131
<field name="living_area">80</field>
127132
<field name="facades">1</field>
128133
<field name="garage">True</field>
134+
<field name="user_id" ref="base.user_admin" />
129135
<field name="garden">False</field>
130136
<field name="garden_area">0</field>
131137
<field name="garden_orientation" />
@@ -160,6 +166,7 @@
160166
<field name="bedrooms">0</field>
161167
<field name="living_area">0</field>
162168
<field name="facades">4</field>
169+
<field name="user_id" ref="base.user_admin" />
163170
<field name="garage">False</field>
164171
<field name="garden">False</field>
165172
<field name="garden_area">0</field>
@@ -179,6 +186,7 @@
179186
<field name="bedrooms">0</field>
180187
<field name="living_area">2000</field>
181188
<field name="facades">2</field>
189+
<field name="user_id" ref="base.user_admin" />
182190
<field name="garage">False</field>
183191
<field name="garden">False</field>
184192
<field name="garden_area">0</field>
@@ -200,6 +208,7 @@
200208
<field name="facades">5</field>
201209
<field name="garage">True</field>
202210
<field name="active">false</field>
211+
<field name="user_id" ref="base.user_admin" />
203212
<field name="garden_area">2000</field>
204213
<field name="garden_orientation">west</field>
205214
<field name="property_type_id" ref="estate_property_type_villa" />

estate/models/estate_property.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@ def _compute_total_area(self):
6868
for record in self:
6969
record.total_area = record.living_area + record.garden_area
7070

71-
@api.onchange("offer_ids")
72-
def _change_state_to_offer_received(self):
73-
for record in self:
74-
if record.state == "new":
75-
if len(record.offer_ids) > 0:
76-
record.state = "offer_received"
77-
7871
@api.depends("offer_ids.price")
7972
def _compute_best_price(self):
8073
for record in self:
@@ -111,7 +104,7 @@ def onclick_cancel(self):
111104
@api.constrains("selling_price")
112105
def _check_selling_price(self):
113106
for record in self:
114-
if record.state not in ["new","offer_received"]:
107+
if record.state not in ["new", "offer_received"]:
115108
if (
116109
float_compare(
117110
record.selling_price,

estate/models/estate_property_offer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def create(self, vals_list):
8383
property_id = vals.get("property_id")
8484
if property_id:
8585
property = self.env["estate.property"].browse(property_id)
86+
if property.state == "new":
87+
property.state = "offer_received"
8688
max_price = max(property.offer_ids.mapped("price"), default=0)
8789
if vals["price"] <= max_price:
8890
raise ValidationError(
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<odoo>
2+
<template id="report_company_information">
3+
<t t-set="company" t-value="company or property.user_id.company_id" />
4+
<div class="company-info" style="margin-bottom:50px;">
5+
<div>
6+
<img
7+
t-if="company.logo"
8+
class="o_company_logo_big"
9+
t-att-src="image_data_uri(company.logo)"
10+
alt="Company Logo"
11+
/>
12+
</div>
13+
<hr />
14+
<div>
15+
<strong t-field="company.name" />
16+
</div>
17+
<div>
18+
<span t-field="company.street" />
19+
</div>
20+
<div>
21+
<span t-field="company.city" />
22+
<span t-field="company.state_id.code" />
23+
<span t-field="company.zip" />
24+
</div>
25+
<div>
26+
<span t-field="company.country_id.name" />
27+
</div>
28+
</div>
29+
</template>
30+
</odoo>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<odoo>
2+
<template id="report_property_offers_table">
3+
<t t-set="offers" t-value="offers" />
4+
<t t-if="offers">
5+
<table class="table">
6+
<thead>
7+
<tr>
8+
<th style="font-weight: bold;">Price</th>
9+
<th style="font-weight: bold;">Partner</th>
10+
<th style="font-weight: bold;">Validity (days)</th>
11+
<th style="font-weight: bold;">Deadline</th>
12+
<th style="font-weight: bold;">Status</th>
13+
</tr>
14+
</thead>
15+
<tbody>
16+
<t t-foreach="offers" t-as="offer">
17+
<tr>
18+
<td>
19+
<span t-field="offer.price" />
20+
</td>
21+
<td>
22+
<span t-field="offer.partner_id" />
23+
</td>
24+
<td>
25+
<span t-field="offer.validity" />
26+
</td>
27+
<td>
28+
<span t-field="offer.date_deadline" />
29+
</td>
30+
<td>
31+
<span t-field="offer.status" />
32+
</td>
33+
</tr>
34+
</t>
35+
</tbody>
36+
</table>
37+
</t>
38+
<t t-else="">
39+
<tr>
40+
<td colspan="5" style="text-align: center; font-style: italic;">
41+
No offers has been made yet :(
42+
</td>
43+
</tr>
44+
</t>
45+
</template>
46+
</odoo>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<odoo>
2+
<record id="action_estate_menu_advertiesments_properties_print_report" model="ir.actions.report">
3+
<field name="name">Real Estate Properties</field>
4+
<field name="model">estate.property</field>
5+
<field name="report_type">qweb-pdf</field>
6+
<field name="report_name">estate.report_estate_property</field>
7+
<field name="report_file">estate.report_estate_property</field>
8+
<field name="binding_model_id" ref="model_estate_property" />
9+
<field name="print_report_name">'Print Report'</field>
10+
<field name="paperformat_id" ref="estate.paperformat_euro_lowmargin" />
11+
</record>
12+
</odoo>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<odoo>
2+
<template id="report_estate_property">
3+
<t t-foreach="docs" t-as="property">
4+
<t t-call="web.html_container">
5+
<t t-call="web.external_layout">
6+
<div class="page">
7+
<t t-call="estate.report_company_information">
8+
<t t-set="company" t-value="property.user_id.company_id" />
9+
</t>
10+
<h1>
11+
<span t-field="property.name" />
12+
</h1>
13+
<div>
14+
<strong>Salesman: </strong>
15+
<span t-field="property.user_id" />
16+
</div>
17+
<div>
18+
<strong>Expected Price: </strong>
19+
<span t-field="property.expected_price" />
20+
</div>
21+
<div id="status">
22+
<strong>Status: </strong>
23+
<span t-field="property.state" />
24+
</div>
25+
<t t-call="estate.report_property_offers_table">
26+
<t t-set="offers" t-value="property.mapped('offer_ids')" />
27+
</t>
28+
</div>
29+
</t>
30+
</t>
31+
</t>
32+
</template>
33+
</odoo>

estate/report/paperformat.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<odoo>
2+
<record id="paperformat_euro_lowmargin" model="report.paperformat">
3+
<field name="name">Euro Paper with Low Margin</field>
4+
<field name="default" eval="False" />
5+
<field name="format">A4</field> <!-- Predefined format -->
6+
<field name="orientation">Portrait</field>
7+
<field name="margin_top">10</field>
8+
<field name="margin_bottom">10</field>
9+
<field name="margin_left">10</field>
10+
<field name="margin_right">10</field>
11+
</record>
12+
</odoo>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<odoo>
2+
<record id="action_print_report_by_saleman" model="ir.actions.report">
3+
<field name="name">Real Estate Property List</field>
4+
<field name="model">res.users</field>
5+
<field name="report_type">qweb-pdf</field>
6+
<field name="report_name">estate.report_property_by_salesman</field>
7+
<field name="report_file">estate.report_property_by_salesman</field>
8+
<field name="print_report_name">'Property Report By Salesman'</field>
9+
<field name="binding_model_id" ref="base.model_res_users" />
10+
<field name="paperformat_id" ref="estate.paperformat_euro_lowmargin" />
11+
</record>
12+
</odoo>

0 commit comments

Comments
 (0)