Skip to content

Commit c17a576

Browse files
committed
[FIX] estate: resolving PR suggestions
1 parent 7d0d446 commit c17a576

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

estate/__manifest__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
{
22
'name': "Real Estate",
33
'summary': "Testing the real estate module",
4-
5-
'description': """
6-
Testing the description real estate module
7-
""",
4+
'description': "Testing the description real estate module",
85
'depends': ['base'],
96
'data': [
107
'security/ir.model.access.csv',

estate/models/estate_property.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class EstateProperty(models.Model):
6464
)
6565

6666
buyer_id = fields.Many2one(
67-
'res.partner', string='Buyer', ondelete='restrict', copy=False, readonly=True
67+
'res.partner', string='Buyer', ondelete='restrict', copy=False, readonly=True,
6868
)
6969

7070
property_tags_ids = fields.Many2many("estate.property.tag", string="Tags")
@@ -81,9 +81,7 @@ def _compute_total_area(self):
8181
@api.depends("offer_ids")
8282
def _compute_best_offer(self):
8383
for record in self:
84-
record.best_offer = 0
85-
for offer in record.offer_ids:
86-
record.best_offer = max(record.best_offer, offer.price)
84+
record.best_offer = max(record.offer_ids.mapped('price'), default=0.0)
8785

8886
@api.onchange("garden")
8987
def _onchange_garden(self):
@@ -104,7 +102,6 @@ def action_mark_as_cancelled(self):
104102
if record.state == "sold":
105103
raise UserError(_("Sold properties cannot be cancelled."))
106104
record.state = "cancelled"
107-
#TODO: Reject all offers
108105
return True
109106

110107
@api.constrains('expected_price')
@@ -113,4 +110,3 @@ def _check_expected_price(self):
113110
for offer in record.offer_ids:
114111
if offer.status == "yes" and float_compare(offer.price, 0.9 * record.expected_price, 2) < 0:
115112
raise ValidationError("There is an accepted offer for an amount less than 90 percent of the new selling price, action required!")
116-

estate/models/estate_property_offer.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def create(self, vals_list):
2626
validity = fields.Integer(default=7)
2727
offer_creation_date = fields.Date(default=fields.Date.today())
2828
deadline = fields.Date(
29-
"Offer Deadline", compute="_compute_deadline", inverse="_inverse_deadline"
29+
"Offer Deadline", compute="_compute_deadline", inverse="_inverse_deadline",
3030
)
3131

3232
partner_id = fields.Many2one(
@@ -65,10 +65,8 @@ def action_accept_offer(self):
6565
return True
6666

6767
def action_reject_offer(self):
68-
for record in self:
69-
record.status = "no"
70-
record.property_id.buyer_id = None
71-
record.property_id.selling_price = 0
68+
self.status = 'no'
69+
self.property_id.write({'buyer_id': None, 'selling_price': 0})
7270
return True
7371

7472
@api.constrains('price')

0 commit comments

Comments
 (0)