Skip to content

Commit e6b30d7

Browse files
committed
[IMP] real_estate: add PDF report generation using QWeb templates
- Implemented custom QWeb PDF reports for real estate properties and offers. - extract offers table into reusable sub-template. - inherit and extend property report to include invoice info for sold properties. - update report styling and layout formatting from wkhtmltopdf package.
1 parent 5e07a63 commit e6b30d7

File tree

5 files changed

+132
-2
lines changed

5 files changed

+132
-2
lines changed

real_estate/__manifest__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
'views/estate_property_tag_view.xml',
1919
'views/res_users_views.xml',
2020
'views/estate_menus.xml',
21+
'report/estate_property_templates.xml',
22+
'report/estate_property_reports.xml',
2123
],
2224
'demo': [
2325
'demo/demo_data.xml',
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<odoo>
3+
<record id="report_estate_property_offer" model="ir.actions.report">
4+
<field name="name">Print Offers</field>
5+
<field name="model">estate.property</field>
6+
<field name="report_type">qweb-pdf</field>
7+
<field name="report_name">real_estate.report_property_offers</field>
8+
<field name="report_file">real_estate.report_property_offers</field>
9+
<field name="print_report_name">'Property Offers - %s' % (object.name).replace('/', '')</field>
10+
<field name="binding_model_id" ref="model_estate_property"/>
11+
</record>
12+
<record id="action_report_user_property_offers" model="ir.actions.report">
13+
<field name="name">Salesman Property Offers</field>
14+
<field name="model">res.users</field>
15+
<field name="binding_model_id" ref="base.model_res_users"/>
16+
<field name="report_type">qweb-pdf</field>
17+
<field name="report_name">real_estate.report_property_user_offers</field>
18+
<field name="report_file">real_estate.report_property_user_offers</field>
19+
<field name="print_report_name">'Salesman Properties - %s' % object.name</field>
20+
</record>
21+
</odoo>
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<odoo>
3+
<template id="property_offer_table_sub">
4+
<t t-if="len(property.offer_ids) > 0">
5+
<p>
6+
<strong>Expected Price:</strong>
7+
<span t-field="property.expected_price" />
8+
</p>
9+
<p>
10+
<strong>Status:</strong>
11+
<span t-field="property.state" />
12+
</p>
13+
<table class="table table-sm mt32" style="width:100%;">
14+
<thead>
15+
<tr>
16+
<th>Price</th>
17+
<th>Partner</th>
18+
<th>Validity (days)</th>
19+
<th>Deadline</th>
20+
<th>Status</th>
21+
</tr>
22+
</thead>
23+
<tbody>
24+
<tr t-foreach="property.offer_ids" t-as="offer">
25+
<td>
26+
<span t-field="offer.price" />
27+
</td>
28+
<td>
29+
<span t-field="offer.partner_id.name" />
30+
</td>
31+
<td>
32+
<span t-field="offer.validity" />
33+
</td>
34+
<td>
35+
<span t-field="offer.date_deadline" />
36+
</td>
37+
<td>
38+
<span t-field="offer.status" />
39+
</td>
40+
</tr>
41+
</tbody>
42+
</table>
43+
</t>
44+
<t t-else="">
45+
<p>
46+
<em>No offers available for this property.</em>
47+
</p>
48+
</t>
49+
</template>
50+
<template id="report_property_offers">
51+
<t t-foreach="docs" t-as="property">
52+
<t t-call="web.html_container">
53+
<t t-call="web.external_layout">
54+
<div class="page">
55+
<h2>
56+
<span t-field="property.name" />
57+
</h2>
58+
<p>
59+
<strong>Salesman:</strong>
60+
<span t-field="property.seller.name" />
61+
</p>
62+
<t t-if="property.offer_ids">
63+
<t t-set="doc" t-value="doc" />
64+
<t t-call="real_estate.property_offer_table_sub" />
65+
</t>
66+
<t t-else="">
67+
<p>
68+
<strong>No offers have been made yet </strong>
69+
</p>
70+
</t>
71+
</div>
72+
</t>
73+
</t>
74+
</t>
75+
</template>
76+
<template id="report_property_user_offers">
77+
<t t-foreach="docs" t-as="salesman">
78+
<t t-call="web.html_container">
79+
<t t-call="web.external_layout">
80+
<div class="page">
81+
<h2>
82+
<strong>Salesman: </strong>
83+
<span t-field="salesman.name" />
84+
</h2>
85+
<t t-if="salesman.property_ids">
86+
<t t-set="properties" t-value="salesman.property_ids" />
87+
<t t-foreach="properties" t-as="property">
88+
<h3>
89+
<span t-field="property.name" />
90+
</h3>
91+
<t t-call="real_estate.property_offer_table_sub" />
92+
</t>
93+
</t>
94+
<strong t-else="">No properties found :</strong>
95+
</div>
96+
</t>
97+
</t>
98+
</t>
99+
</template>
100+
<template id="inherit_property_offer_table_sub" inherit_id="real_estate.report_property_offers">
101+
<xpath expr="//div[hasclass('page')]" position="inside">
102+
<t t-if="property.state == 'sold'">
103+
<p>!!! Invoice has already been created !!!</p>
104+
</t>
105+
</xpath>
106+
</template>
107+
</odoo>

real_estate/security/estate_property_rules.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
]</field>
3232
<field name="groups" eval="[(4, ref('estate_group_user'))]" />
3333
</record>
34-
</odoo>
34+
</odoo>

real_estate/security/estate_security.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
<field name="category_id" ref="base.module_category_real_estate_brokerage"></field>
99
<field name="implied_ids" eval="[(4, ref('estate_group_user'))]"></field>
1010
</record>
11-
</odoo>
11+
</odoo>

0 commit comments

Comments
 (0)