Skip to content

Commit cf3e70b

Browse files
committed
[ADD] real_estate: Added mail templates and QWeb report templates
Implemented mail templates and QWeb report definitions. Added XML structures for email content and report layouts.
1 parent 87d4023 commit cf3e70b

File tree

11 files changed

+168
-19
lines changed

11 files changed

+168
-19
lines changed

awesome_dashboard/__manifest__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
],
2424
'assets': {
2525
'web.assets_backend': [
26-
'awesome_dashboard/static/src/**/*',
26+
# 'awesome_dashboard/static/src/**/*',
27+
'awesome_dashboard/static/src/**/*.js',
28+
'awesome_dashboard/static/src/**/*.xml',
29+
'awesome_dashboard/static/src/**/*.scss',
2730
],
2831
},
2932
'license': 'AGPL-3'
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
/** @odoo-module **/
2+
13
import { Component } from "@odoo/owl";
24
import { registry } from "@web/core/registry";
5+
import { Layout } from "@web/search/layout";
36

4-
class AwesomeDashboard extends Component {
7+
export class AwesomeDashboard extends Component {
58
static template = "awesome_dashboard.AwesomeDashboard";
9+
static components = { Layout };
610
}
7-
8-
registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard);
11+
registry
12+
.category("actions")
13+
.add("awesome_dashboard.dashboard", AwesomeDashboard);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.o_dashboard {
2+
background-color: #d3d3d3;
3+
}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
<?xml version="1.0" encoding="UTF-8" ?>
1+
<?xml version="1.0" encoding="UTF-8"?>
22
<templates xml:space="preserve">
33

44
<t t-name="awesome_dashboard.AwesomeDashboard">
5-
hello dashboard
5+
<Layout display="{ controlPanel: {} }" className="'o_dashboard h-100'">
6+
<div class="p-3">
7+
<h2>Awesome Dashboard</h2>
8+
<p>This is my first dashboard using Layout</p>
9+
</div>
10+
</Layout>
611
</t>
712

8-
</templates>
13+
</templates>

awesome_dashboard/views/views.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<odoo>
22
<data>
33
<record model="ir.actions.client" id="dashboard">
4-
<field name="name">Dashboard</field>
4+
<field name="name">Rugot</field>
55
<field name="tag">awesome_dashboard.dashboard</field>
66
</record>
77

real_estate/__manifest__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
'views/res_users_views.xml',
1919
'views/real_estate_property_investor_views.xml',
2020
'views/real_estate_menus.xml',
21-
'data/real_estate_demo_data.xml'
21+
'data/real_estate_demo_data.xml',
22+
'data/mail_template_data.xml',
23+
'report/report_action.xml',
24+
'report/report_property_sale.xml',
2225
],
2326
'application': True,
2427
'installable': True,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<odoo>
2+
<data>
3+
<record id="mail_template_data_real_estate" model="mail.template">
4+
<field name="name">Real estate: Property Sale Acknowledgment</field>
5+
<field name="model_id" ref="real_estate.model_real_estate"/>
6+
<field name="subject">{{ object.name }}</field>
7+
<field name="email_from">{{ object.buyer_id.email }}</field>
8+
<field name="use_default_to" eval="True"/>
9+
<field name="description">Automatically send an email to customers when a property sold</field>
10+
<field name="body_html" type="html">
11+
<div>
12+
Dear,
13+
<br/>
14+
Buyer name :
15+
<t t-out="object.buyer_id.name"/>
16+
Selling Price :
17+
<t t-out="object.selling_price"/>
18+
Sales Person :
19+
<t t-out="object.salesperson_id.name"/>
20+
Property Name :
21+
<t t-out="object.name"/>
22+
<br/>
23+
Thank you for contacting us. We appreciate your interest in our property.
24+
<br/>
25+
If you have any further questions or concerns in the meantime, please do not hesitate to let us
26+
know. We are here to help.
27+
<br/>
28+
<br/>
29+
Thank you for your patience.
30+
<br/>
31+
Best regards,
32+
</div>
33+
</field>
34+
</record>
35+
</data>
36+
</odoo>

real_estate/models/real_estate_property.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,38 @@ def action_sold(self):
172172
raise UserError("Property cannot be sold , there is any maintenance request not done")
173173
if not self.selling_price or not self.buyer_id:
174174
raise UserError("Cannot sell without a selling price and buyer.")
175+
176+
ctx = {
177+
'default_model': 'real.estate',
178+
'default_res_ids': self.ids,
179+
'default_partner_ids': [
180+
self.buyer_id.id,
181+
self.salesperson_id.partner_id.id
182+
],
183+
}
184+
mail_template = self.env.ref('real_estate.mail_template_data_real_estate')
185+
if mail_template:
186+
ctx.update({
187+
'default_template_id': mail_template.id,
188+
189+
})
190+
action = {
191+
'name': _('Send'),
192+
'type': 'ir.actions.act_window',
193+
'view_mode': 'form',
194+
'res_model': 'mail.compose.message',
195+
'views': [(False, 'form')],
196+
'view_id': False,
197+
'target': 'new',
198+
'context': ctx,
199+
}
175200
self.stage = 'sold'
201+
return action
176202

177203
def action_best_offer(self):
178204
for record in self.offer_ids:
179205
if record.price == self.best_price:
180206
record.action_accept()
207+
208+
def action_print_sale_doc(self):
209+
return self.env.ref('real_estate.real_estate_report_action_property_sale').report_action(self)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<odoo>
2+
<record id="real_estate_report_action_property_sale" model="ir.actions.report">
3+
<field name="name">Property Sale PDF</field>
4+
<field name="model">real.estate</field>
5+
<field name="report_type">qweb-pdf</field>
6+
<field name="report_name">real_estate.report_property_sale</field>
7+
<field name="report_file">real_estate.report_property_sale</field>
8+
<field name="print_report_name">'Property Sale - %s' % (object.name)</field>
9+
</record>
10+
</odoo>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<odoo>
2+
<template id="report_property_sale">
3+
<t t-foreach="docs" t-as="o">
4+
<t t-call="web.html_container">
5+
<t t-call="web.external_layout">
6+
<div class="page">
7+
<hr/>
8+
<h2 style="text-align:center;">Property Sale Confirmation</h2>
9+
<p>
10+
<strong>Property Name:</strong>
11+
<t t-esc="o.name"/>
12+
</p>
13+
<p>
14+
<strong>Buyer:</strong>
15+
<t t-esc="o.buyer_id.name"/>
16+
</p>
17+
<p>
18+
<strong>Seller:</strong>
19+
<t t-esc="o.salesperson_id.name"/>
20+
</p>
21+
<p>
22+
<strong>Sale Price:</strong>
23+
24+
<t t-esc="o.selling_price"/>
25+
</p>
26+
<p>
27+
<strong>Sale Date:</strong>
28+
<t t-esc="o.write_date"/>
29+
</p>
30+
31+
<table class="table table-sm mt32">
32+
<tr>
33+
<th>Type</th>
34+
<th>Area</th>
35+
<th>Bedrooms</th>
36+
<th>Bathrooms</th>
37+
</tr>
38+
<tr>
39+
<td>
40+
<t t-esc="o.property_type_id.name"/>
41+
</td>
42+
</tr>
43+
</table>
44+
<p class="mt32">This document confirms the successful sale of the above property.</p>
45+
</div>
46+
</t>
47+
</t>
48+
</t>
49+
</template>
50+
</odoo>

0 commit comments

Comments
 (0)