Skip to content

Commit bee76c5

Browse files
committed
[IMP] improved code readability and deleted duplicates
1 parent 24472f8 commit bee76c5

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

estate/models/estate_property.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ class Property(models.Model):
5454
total_area = fields.Float("Total area (sqm)", compute="_compute_area")
5555
best_price = fields.Float("Best price", compute="_compute_best_price")
5656

57-
@api.constrains("expected_price", "selling_price")
58-
def _check_price(self):
59-
for record in self:
60-
if record.selling_price and record.expected_price and not tools.float_utils.float_is_zero(record.selling_price, precision_digits=2):
61-
if record.selling_price < 0.9 * record.expected_price:
62-
raise exceptions.ValidationError(
63-
"The selling price cannot be lower than 90% of the expected price.")
64-
6557
@api.depends("living_area", "garden_area")
6658
def _compute_area(self):
6759
for record in self:
@@ -70,7 +62,7 @@ def _compute_area(self):
7062
@api.depends("offer_ids.price")
7163
def _compute_best_price(self):
7264
for record in self:
73-
record.best_price = max([0]+record.offer_ids.mapped('price'))
65+
record.best_price = max([0] + record.offer_ids.mapped('price'))
7466

7567
@api.onchange("garden")
7668
def _onchange_garden(self):
@@ -109,7 +101,6 @@ def _check_price(self):
109101
if record.selling_price < 0.9 * record.expected_price:
110102
raise exceptions.ValidationError(
111103
"The selling price cannot be lower than 90% of the expected price.")
112-
113104

114105
@api.ondelete(at_uninstall=False)
115106
def _not_delete_if_not_new_or_canceled(self):

0 commit comments

Comments
 (0)