[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) <paso@odoo.com>
This commit is contained in:
paso-odoo
2023-06-05 07:04:50 +02:00
parent 8d551f9d32
commit bafc5610b0
2 changed files with 12 additions and 0 deletions
+7
View File
@@ -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 ""
@@ -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