From bafc5610b0b43901498eeaa29482f82fc910eba5 Mon Sep 17 00:00:00 2001 From: paso-odoo Date: Tue, 30 May 2023 06:32:53 +0000 Subject: [PATCH] [FIX] product: fix negative rounding method for pricelist If applied, this commit will solve the issue of the rounding method AssertionError while configuring any negative value in pricelists. Steps to produce: - Open Sale > Products > Pricelists > Create/Open any Pricelist. - Add a new line in Pricelist Rules. - Set computation as 'Formula'. - In the Rounding Method field configure any negative value i.e. -1.56. - Error will be raised. Fix this issue by preventing the user from entering the negative value in Rounding Method. Sentry-4208813474 closes odoo/odoo#123539 X-original-commit: f7b0eddf3124b15bb223379a513965fa2a017851 Signed-off-by: Parth Solanki (paso) --- addons/product/i18n/product.pot | 7 +++++++ addons/product/models/product_pricelist_item.py | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/addons/product/i18n/product.pot b/addons/product/i18n/product.pot index ba1b5a87638..c46b498d459 100644 --- a/addons/product/i18n/product.pot +++ b/addons/product/i18n/product.pot @@ -2549,6 +2549,13 @@ msgid "" "unit of measure of the product otherwise." msgstr "" +#. module: product +#. odoo-python +#: code:addons/product/models/product_pricelist_item.py:0 +#, python-format +msgid "The rounding method must be strictly positive." +msgstr "" + #. module: product #: model:ir.model.fields,help:product.field_product_product__lst_price msgid "" diff --git a/addons/product/models/product_pricelist_item.py b/addons/product/models/product_pricelist_item.py index 61e59aba56a..571f44c957e 100644 --- a/addons/product/models/product_pricelist_item.py +++ b/addons/product/models/product_pricelist_item.py @@ -262,6 +262,11 @@ class PricelistItem(models.Model): template_rules.update({'applied_on': '1_product'}) (self-variants_rules-template_rules).update({'applied_on': '3_global'}) + @api.onchange('price_round') + def _onchange_price_round(self): + if any(item.price_round and item.price_round < 0.0 for item in self): + raise ValidationError(_("The rounding method must be strictly positive.")) + #=== CRUD METHODS ===# @api.model_create_multi