Skip to content

Commit 9402844

Browse files
committed
IMP] estate, estate_account: implement and extend PDF property reports
-Created a PDF report for estate properties listing all property offers using QWeb templates and report actions. -Extended the report in estate_account to include invoice details for sold properties. -Organized templates and report actions within their respective modules. -Updated manifest files to register new reports. -Enhances reporting by allowing users to generate comprehensive property and financial documents from the UI.
1 parent 532c013 commit 9402844

File tree

6 files changed

+145
-4
lines changed

6 files changed

+145
-4
lines changed

estate/__manifest__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
"installable": True,
66
"data": [
77
"security/security.xml",
8+
"security/ir.model.access.csv",
89
"data/property_type.xml",
910
"views/estate_property_views.xml",
1011
"views/estate_property_tag_views.xml",
1112
"views/estate_property_offer_views.xml",
1213
"views/estate_property_type_views.xml",
1314
"views/estate_menus.xml",
1415
"views/inherit_res_users_view.xml",
15-
"security/ir.model.access.csv",
16+
"report/estate_property_templates.xml",
17+
"report/estate_property_reports.xml"
1618
],
1719
"demo": [
1820
"demo/property.xml",

estate/models/estate_property.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def action_sell_property(self):
135135
for record in self:
136136
if property_sell_status_dict[record.status]:
137137
record.status = "sold"
138+
record.state = "sold"
138139
else:
139140
raise UserError("Cancelled property cannot be sold.")
140141

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<odoo>
2+
<record id="report_event_registration_badge" model="ir.actions.report">
3+
<field name="name">Property Offers</field>
4+
<field name="model">estate.property</field>
5+
<field name="report_type">qweb-pdf</field>
6+
<field name="report_name">estate.report_property_offers</field>
7+
<field name="report_file">estate.report_property_offers</field>
8+
<field name="print_report_name">'Property Offers - %s' % (object.name).replace('/','')</field>
9+
<field name="binding_model_id" ref="model_estate_property"/>
10+
<field name="binding_type">report</field>
11+
</record>
12+
13+
<record id="action_report_user_properties" model="ir.actions.report">
14+
<field name="name">User Properties</field>
15+
<field name="model">res.users</field>
16+
<field name="report_type">qweb-pdf</field>
17+
<field name="report_name">estate.report_user_properties</field>
18+
<field name="report_file">estate.report_user_properties</field>
19+
<field name="binding_model_id" ref="base.model_res_users"/>
20+
<field name="binding_type">report</field>
21+
<field name="print_report_name">'User Properties - %s' % (object.name)</field>
22+
</record>
23+
</odoo>
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<odoo>
2+
<template id="report_property_offers">
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+
<h2>
8+
<span t-field="property.name"/>
9+
</h2>
10+
<div>
11+
<strong>Salesman: </strong>
12+
<span t-field="property.user_id"/>
13+
</div>
14+
<div>
15+
<strong>Expected Price: </strong>
16+
<span t-field="property.expected_price"/>
17+
</div>
18+
<div>
19+
<strong>Status: </strong>
20+
<span t-field="property.state"/>
21+
</div>
22+
<div class="invoice_info">
23+
</div>
24+
<t t-set="object" t-value="property"/>
25+
<t t-call="estate.report_property_offers_table"/>
26+
</div>
27+
</t>
28+
</t>
29+
</t>
30+
</template>
31+
32+
<template id="report_property_offers_table">
33+
<t t-if="object.mapped('offer_ids')">
34+
<table class="table">
35+
<thead>
36+
<tr>
37+
<th>Price</th>
38+
<th>Partner</th>
39+
<th>Validity(days)</th>
40+
<th>Deadline</th>
41+
<th>Status</th>
42+
</tr>
43+
</thead>
44+
<tbody>
45+
<t t-set="offers" t-value="object.mapped('offer_ids')"/>
46+
<tr t-foreach="offers" t-as="offer">
47+
<td>
48+
<span t-field="offer.price"/>
49+
</td>
50+
<td>
51+
<span t-field="offer.partner_id"/>
52+
</td>
53+
<td>
54+
<span t-field="offer.validity"/>
55+
</td>
56+
<td>
57+
<span t-field="offer.date_deadline"/>
58+
</td>
59+
<td>
60+
<span t-field="offer.status"/>
61+
</td>
62+
</tr>
63+
</tbody>
64+
</table>
65+
</t>
66+
<t t-else="">
67+
<p>No offers yet for this property.</p>
68+
</t>
69+
</template>
70+
71+
<template id="report_user_properties">
72+
<t t-foreach="docs" t-as="user">
73+
<t t-call="web.html_container">
74+
<t t-call="web.external_layout">
75+
<div class="page">
76+
<h2>
77+
Salesman <span t-field="user.name"/>
78+
</h2>
79+
<t t-if="user.property_ids">
80+
<t t-foreach="user.property_ids" t-as="property">
81+
<div class="mt-3">
82+
<h2>
83+
<span t-field="property.name"/>
84+
</h2>
85+
<div>
86+
<strong>Expected Price:</strong>
87+
<span t-field="property.expected_price"/>
88+
</div>
89+
<div>
90+
<strong>Status:</strong>
91+
<span t-field="property.state"/>
92+
</div>
93+
<t t-set="object" t-value="property"/>
94+
<t t-call="estate.report_property_offers_table"/>
95+
</div>
96+
<hr/>
97+
</t>
98+
</t>
99+
<t t-else="">
100+
<p><i>This user has no properties assigned as Salesman.</i></p>
101+
</t>
102+
</div>
103+
</t>
104+
</t>
105+
</t>
106+
</template>
107+
108+
<template id="report_property_offers_inherit_invoice" inherit_id="estate.report_property_offers" priority="20">
109+
<xpath expr="//div[hasclass('invoice_info')]" position="inside">
110+
<t t-if="property.state == 'sold'">
111+
<div class="mt-4">
112+
<p>The invoice has already been creted!!!</p>
113+
</div>
114+
</t>
115+
</xpath>
116+
</template>
117+
</odoo>

estate/security/ir.model.access.csv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,3 @@ estate.access_estate_property_tag_to_agent,Estate Agent,model_estate_property_ta
1515
estate.access_estate_property_to_agent,Estate Agent,model_estate_property,estate.estate_group_user,1,1,1,0
1616

1717
access_estate_model_offer,estate.property.offer,model_estate_property_offer,base.group_user,1,1,1,1
18-
19-

estate_account/models/estate_property.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def action_sell_property(self):
2626
"partner_id": partner_id.id,
2727
"move_type": "out_invoice",
2828
"journal_id": journal.id,
29+
"company_id": record.company_id.id,
2930
"line_ids": [
3031
Command.create(
3132
{
@@ -51,5 +52,4 @@ def action_sell_property(self):
5152
],
5253
}
5354
)
54-
5555
return super().action_sell_property()

0 commit comments

Comments
 (0)