Skip to content

Commit 156ec9a

Browse files
committed
[IMP] estate: added Accept,Refuse buttons & related functionality in Real Estate
Added Accept and Refuse buttons along with the supporting functionality to improve workflow in the Real Estate module.
1 parent f93dec0 commit 156ec9a

File tree

7 files changed

+23
-25
lines changed

7 files changed

+23
-25
lines changed

estate/__manifest__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
'data': [
55
'security/ir.model.access.csv',
66
'views/estate_property_views.xml',
7-
'views/estate_menus.xml',
87
'views/estate_property_type_views.xml',
98
'views/estate_property_tag_views.xml',
10-
'views/estate_property_offer_views.xml'
9+
'views/estate_property_offer_views.xml',
10+
'views/estate_menus.xml'
1111
],
1212
'application': True,
13-
'installable':True
13+
'installable': True,
14+
'author': 'Odoo S.A.',
15+
'license': 'LGPL-3'
1416
}

estate/models/estate_property.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from odoo import models, fields, api
22
from dateutil.relativedelta import relativedelta
3-
from datetime import date
43
from odoo.exceptions import UserError
54

65

@@ -51,20 +50,20 @@ class EstateProperty(models.Model):
5150
offer_ids = fields.One2many("estate.property.offer", "property_id", "Offers")
5251
total_area = fields.Integer("Total Area(sqm)", compute="_compute_total_area")
5352
best_price = fields.Float("Best Offer", compute="_compute_best_price")
54-
53+
5554
@api.depends("living_area", "garden_area")
5655
def _compute_total_area(self):
5756
for record in self:
5857
record.total_area = record.living_area + record.garden_area
59-
58+
6059
@api.depends("offer_ids.price")
6160
def _compute_best_price(self):
6261
for record in self:
6362
if record.offer_ids:
6463
record.best_price = max(record.offer_ids.mapped("price"))
6564
else:
6665
record.best_price = 0
67-
66+
6867
@api.onchange('garden')
6968
def _onchange_garden(self):
7069
if self.garden:

estate/models/estate_property_offer.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,16 @@ def _inverse_date_deadline(self):
3030
record.validity = (record.date_deadline - fields.Date.to_date(record.create_date)).days
3131
else:
3232
record.validity = False
33+
34+
def action_accept(self):
35+
for record in self:
36+
record.status = "accepted"
37+
record.property_id.selling_price = record.price
38+
record.property_id.buyer_id = record.partner_ids
39+
record.property_id.state = "offer_accepted"
40+
return True
41+
42+
def action_refuse(self):
43+
for record in self:
44+
record.status = 'refused'
45+
return True

estate/models/estate_property_tag.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ class EstatePropertyTag(models.Model):
66
_description = "Real Estate Property Tag"
77

88
name = fields.Char(required=True)
9-

estate/models/estate_property_type.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ class EstatePropertyType(models.Model):
66
_description = "Real Estate Property Type"
77

88
name = fields.Char(required=True)
9-

estate/views/estate_property_offer_views.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<field name="status" />
1010
<field name="validity" />
1111
<field name="date_deadline" />
12+
<button name="action_accept" type="object" string="Accept" icon="fa-check"/>
13+
<button name="action_refuse" type="object" string="Refuse" icon="fa-times"/>
1214
</list>
1315
</field>
1416
</record>

estate/views/estate_property_views.xml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,6 @@
6868

6969
<page string="Offers">
7070
<field name="offer_ids">
71-
<list>
72-
<field name="price" />
73-
<field name="partner_id" />
74-
<field name="status" />
75-
<field name="validity" />
76-
<field name="date_deadline" />
77-
</list>
78-
<form>
79-
<group>
80-
<field name="price" />
81-
<field name="partner_id" />
82-
<field name="status" />
83-
<field name="validity" />
84-
<field name="date_deadline" />
85-
</group>
86-
</form>
8771
</field>
8872
</page>
8973

0 commit comments

Comments
 (0)