changeset 6d72ded73e3f in modules/sale_promotion:default
details:
https://hg.tryton.org/modules/sale_promotion?cmd=changeset;node=6d72ded73e3f
description:
Apply promotion on any line reduced
This is what customers are expecting when promotions and price list are
in
competition.
issue9406
review297941002
diffstat:
CHANGELOG | 2 ++
sale.py | 13 ++++++-------
2 files changed, 8 insertions(+), 7 deletions(-)
diffs (39 lines):
diff -r 84141ac2b2fe -r 6d72ded73e3f CHANGELOG
--- a/CHANGELOG Mon May 04 12:27:55 2020 +0200
+++ b/CHANGELOG Wed Jun 24 22:59:23 2020 +0200
@@ -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 -r 84141ac2b2fe -r 6d72ded73e3f sale.py
--- a/sale.py Mon May 04 12:27:55 2020 +0200
+++ b/sale.py Wed Jun 24 22:59:23 2020 +0200
@@ -236,20 +236,19 @@
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):