From c3304c04935c262fd4ea60eab8a8cb1c1a19423c Mon Sep 17 00:00:00 2001 From: Reyes4711-S73 Date: Mon, 27 May 2024 13:12:48 +0200 Subject: [PATCH] [16.0][FIX] sale_fixed_discount When you are fixing a new discount, the constain is not doing properly the rounding and it's showing all decimal values, producing the validation error due to the mentioned issue --- sale_fixed_discount/models/sale_order_line.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sale_fixed_discount/models/sale_order_line.py b/sale_fixed_discount/models/sale_order_line.py index 9ba6521b11d..4f57aaf689c 100644 --- a/sale_fixed_discount/models/sale_order_line.py +++ b/sale_fixed_discount/models/sale_order_line.py @@ -18,19 +18,18 @@ class SaleOrderLine(models.Model): @api.constrains("discount_fixed", "discount") def _check_discounts(self): """Check that the fixed discount and the discount percentage are consistent.""" + precision = self.env["decimal.precision"].precision_get("Discount") for line in self: if line.discount_fixed and line.discount: - currency = line.currency_id calculated_fixed_discount = float_round( line._get_discount_from_fixed_discount(), - precision_rounding=currency.rounding, + precision_digits=precision, ) - if ( float_compare( calculated_fixed_discount, line.discount, - precision_rounding=currency.rounding, + precision_digits=precision, ) != 0 ):