Skip to content

Commit 2d8b90a

Browse files
committed
[FIX] estate: fix edge-case in validation of a new offer's price
A new offer's price must be at least equal to the one of the best existing offer. We use the "best_price" computed field on "estate.property" for this and we must account for the case when it hasn't been initialized yet. In that case, use 0 as a fallback.
1 parent ea1aaa7 commit 2d8b90a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

estate/models/estate_property_offer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def _inverse_deadline(self) -> None:
3939
def create(self, vals):
4040
for val in vals:
4141
estate_property = self.env["estate.property"].browse(val["property_id"])
42-
if val["price"] < estate_property.best_price:
42+
best_price = estate_property.best_price or 0.0
43+
if val["price"] < best_price:
4344
raise UserError(_("A new offer must match or exceed the price of the current best offer."))
4445
estate_property.state = "offer_received"
4546
return super().create(vals)

0 commit comments

Comments
 (0)