From 3c1dbf05e655f3c8af46ed05fbc496e1228fb64d Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Tue, 19 Nov 2024 10:27:39 +0100 Subject: [PATCH] [FIX] loyalty_criteria_multi_product: Avoiding cross-data in multi-product promotion criteria When setting up a multi-product promotion, you should not set a minimum spend amount because if one rule passes, they will all pass. To avoid misconfiguration, the field is hidden for promotions with multi-product criteria. In addition, the rule data is cleared when the criterion is changed so that the promotion is applied correctly in case of promotion modifications. --- .../models/loyalty_rule.py | 3 +++ .../views/loyalty_rule_views.xml | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/loyalty_criteria_multi_product/models/loyalty_rule.py b/loyalty_criteria_multi_product/models/loyalty_rule.py index f54c906f5..c8c861ea4 100644 --- a/loyalty_criteria_multi_product/models/loyalty_rule.py +++ b/loyalty_criteria_multi_product/models/loyalty_rule.py @@ -24,7 +24,10 @@ class LoyaltyRule(models.Model): def _onchange_loyalty_criteria(self): """Clear domain so we clear some other fields from the view""" if self.loyalty_criteria == "multi_product": + self.minimum_amount = 0.00 self.product_domain = False self.product_ids = False self.product_category_id = False self.product_tag_id = False + else: + self.loyalty_criteria_ids = False diff --git a/loyalty_criteria_multi_product/views/loyalty_rule_views.xml b/loyalty_criteria_multi_product/views/loyalty_rule_views.xml index 70d0b9d00..244c8465e 100644 --- a/loyalty_criteria_multi_product/views/loyalty_rule_views.xml +++ b/loyalty_criteria_multi_product/views/loyalty_rule_views.xml @@ -9,6 +9,21 @@ name="attrs" >{'invisible': [('loyalty_criteria', '!=', 'domain')]} + + {'invisible': [('loyalty_criteria', '!=', 'domain')]} + + +
+ {'invisible': [('loyalty_criteria', '!=', 'domain')]} +