Skip to content

Commit e55461d

Browse files
committed
[ADD] estate: PDF report added
1 parent e215da5 commit e55461d

File tree

6 files changed

+217
-18
lines changed

6 files changed

+217
-18
lines changed

estate/__manifest__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
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',

estate/models/estate_property_offer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def action_confirm(self):
4848
})
4949
(record.property_id.offer_ids - record).write({'status': 'refused'})
5050

51-
5251
def action_refuse(self):
5352
for record in self:
5453
record.status = 'refused'
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_views.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@
7777
<field name="state" widget="statusbar" statusbar_visible="new,offer received,offer accepted,sold"/>
7878
</header>
7979
<sheet>
80+
<div class="oe_button_box" name="button_box">
81+
<button name="%(estate.estate_property_offer_reports)d"
82+
class="oe_stat_button"
83+
type="action"
84+
icon="fa-print"
85+
string="Print" />
86+
</div>
8087
<h1 class="mb32">
8188
<field name="name" class="mb16"/>
8289
</h1>

estate/views/res_users_views.xml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,30 @@
55
<field name="model">res.users</field>
66
<field name="inherit_id" ref="base.view_users_form"/>
77
<field name="arch" type="xml">
8-
<notebook position="inside">
9-
<page string="Real Estate Properties">
10-
<field name="property_ids">
11-
<list>
12-
<field name="name"/>
13-
<field name="property_type_id" />
14-
<field name="postcode" />
15-
<field name="property_tag_ids" widget="many2many_tags" options="{'color_field': 'color', 'editable' : 'true' }" />
16-
<field name="bedrooms" />
17-
<field name="living_area" />
18-
<field name="expected_price"/>
19-
<field name="selling_price" />
20-
<field name="date_avaiblity" optional = "hide"/>
21-
</list>
22-
</field>
23-
</page>
24-
</notebook>
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>
15+
<notebook position="inside">
16+
<page string="Real Estate Properties">
17+
<field name="property_ids">
18+
<list>
19+
<field name="name"/>
20+
<field name="property_type_id" />
21+
<field name="postcode" />
22+
<field name="property_tag_ids" widget="many2many_tags" options="{'color_field': 'color', 'editable' : 'true' }" />
23+
<field name="bedrooms" />
24+
<field name="living_area" />
25+
<field name="expected_price"/>
26+
<field name="selling_price" />
27+
<field name="date_avaiblity" optional = "hide"/>
28+
</list>
29+
</field>
30+
</page>
31+
</notebook>
2532
</field>
2633
</record>
2734
</odoo>

0 commit comments

Comments
 (0)