[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
This commit is contained in:
Nicolas Lempereur
2017-10-04 19:12:40 +02:00
parent 29a5de310e
commit 8aef2eb92d
+3 -1
View File
@@ -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')