From a66ece3d4d8874a2f50794e734b311cf01d63a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 2 Aug 2023 19:09:51 +0200 Subject: [PATCH] Skip promotion based on categories if line has no product Closes #12351 (grafted from ca27ba40eda89e3933e595810eab24fe25504ef7) --HG-- branch : 6.0 --- modules/sale_promotion/sale.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/sale_promotion/sale.py b/modules/sale_promotion/sale.py index f341f6256a..9fe0fc2e2e 100644 --- a/modules/sale_promotion/sale.py +++ b/modules/sale_promotion/sale.py @@ -282,12 +282,13 @@ class Promotion( return False elif self.products and line.product not in self.products: return False - elif (self.categories - and not set(parents(line.product.categories_all)).intersection( - self.categories)): - return False - else: - return True + elif self.categories: + if not line.product: + return False + categories = set(parents(line.product.categories_all)) + if not categories.intersection(self.categories): + return False + return True def apply(self, sale): applied = False