From 8aef2eb92d97c6f401d2b03a3ab00fe2e352d017 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 4 Oct 2017 16:56:00 +0200 Subject: [PATCH] [FIX] sale_coupon: error only one of begin/end set If a promotion program has a start date without a end date, or a end date without a start date, there was an error of comparing string to boolean opw-775236 --- models/sale_coupon_rules.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/models/sale_coupon_rules.py b/models/sale_coupon_rules.py index 6495b6421b2..a7e9405fa54 100644 --- a/models/sale_coupon_rules.py +++ b/models/sale_coupon_rules.py @@ -28,7 +28,9 @@ class SaleCouponRule(models.Model): @api.constrains('rule_date_to', 'rule_date_from') def _check_rule_date_from(self): - if self.filtered(lambda applicability: applicability.rule_date_to < applicability.rule_date_from): + if any(applicability for applicability in self + if applicability.rule_date_to and applicability.rule_date_from + and applicability.rule_date_to < applicability.rule_date_from): raise ValidationError(_('The start date must be before the end date')) @api.constrains('rule_minimum_amount')