changeset 0f2befb01e31 in modules/sale_promotion:default
details: 
https://hg.tryton.org/modules/sale_promotion?cmd=changeset&node=0f2befb01e31
description:
        Do not apply negative unit price after promotion

        We must just set a unit price of 0.

        issue10903
        review377421002
diffstat:

 sale.py |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (21 lines):

diff -r 263a96bd1a3f -r 0f2befb01e31 sale.py
--- a/sale.py   Fri Sep 17 10:30:03 2021 +0200
+++ b/sale.py   Sat Oct 30 02:07:55 2021 +0200
@@ -282,10 +282,13 @@
                 continue
             context = self.get_context_formula(line)
             new_price = self.get_unit_price(**context)
-            if new_price is not None and line.unit_price >= new_price:
-                line.unit_price = round_price(new_price)
-                line.promotion = self
-                applied = True
+            if new_price is not None:
+                if new_price < 0:
+                    new_price = Decimal(0)
+                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
 

Reply via email to