diff --git a/CHANGELOG b/CHANGELOG index f460937bc1..1827e74f49 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Apply promotion on any reduced line + Version 5.6.0 - 2020-05-04 * Bug fixes (see mercurial logs for details) diff --git a/sale.py b/sale.py index b75ea903b2..1bfc861a20 100644 --- a/sale.py +++ b/sale.py @@ -236,20 +236,19 @@ class Promotion( return True def apply(self, sale): - new_prices = {} + applied = False for line in sale.lines: if line.type != 'line': continue if not self.is_valid_sale_line(line): continue context = self.get_context_formula(line) - new_prices[line] = self.get_unit_price(**context) - - # Apply promotion only if all unit prices decrease - if all(l.unit_price >= p for l, p in new_prices.items()): - for line, unit_price in new_prices.items(): - line.unit_price = round_price(unit_price) + new_price = self.get_unit_price(**context) + if line.unit_price >= new_price: + line.unit_price = round_price(new_price) line.promotion = self + applied = True + if applied: sale.lines = sale.lines # Trigger the change def get_context_formula(self, sale_line):