From 65905144eb800c424006dea753ca17ebaf140644 Mon Sep 17 00:00:00 2001 From: Ilyas Date: Thu, 22 Jun 2023 12:28:24 +0200 Subject: [PATCH] [FIX] sale_commission_product_criteria_discount: reset distount when based_on is changed --- .../models/commission.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sale_commission_product_criteria_discount/models/commission.py b/sale_commission_product_criteria_discount/models/commission.py index 24f55463e..b9d8e2d47 100644 --- a/sale_commission_product_criteria_discount/models/commission.py +++ b/sale_commission_product_criteria_discount/models/commission.py @@ -15,6 +15,11 @@ class CommissionItem(models.Model): discount_from = fields.Float("Discount From") discount_to = fields.Float("Discount To") + @api.onchange("based_on") + def onchange_based_on(self): + if self.based_on != "discount": + self.update({"discount_from": 0, "discount_to": 0}) + @api.constrains("discount_from", "discount_to") def _check_discounts(self): if any(item.discount_from > item.discount_to for item in self):