Skip to content

Commit e205ffa

Browse files
committed
[FIX] estate_account: correct admin fees and use float_compare
- Restore "Administrative fees" invoice line with fixed amount (100.0) - Use float_compare for selling price constraint to handle rounding safely - Prevents false ValidationErrors and ensures invoice lines follow business logic
1 parent dffa3b2 commit e205ffa

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

estate/models/estate_property.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from odoo import models, fields, api
22
from odoo.exceptions import UserError, ValidationError
3+
from odoo.tools.float_utils import float_compare
34
from dateutil.relativedelta import relativedelta
45

56

@@ -133,9 +134,10 @@ def action_sold(self):
133134
@api.constrains("selling_price", "expected_price")
134135
def _check_selling_price_min(self):
135136
for record in self:
136-
if (
137-
record.selling_price and record.expected_price and record.selling_price < record.expected_price * 0.9
138-
):
137+
if not record.selling_price or not record.expected_price:
138+
continue
139+
# approximate comparison: selling_price >= 90% of expected_price
140+
if float_compare(record.selling_price, record.expected_price * 0.9, precision_digits=2) < 0:
139141
raise ValidationError(
140142
"The selling price cannot be lower than 90% of the expected price."
141143
)

estate_account/models/estate_property.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ def action_sold(self):
2828
"price_unit": property.selling_price * 0.06,
2929
}),
3030
Command.create({
31-
"name": f"Selling price for {property.name}",
31+
"name": "Administrative fees",
3232
"quantity": 1,
33-
"price_unit": property.selling_price,
33+
"price_unit": 100,
3434
}),
3535
],
3636
}

0 commit comments

Comments
 (0)