changeset e646c3af990e in modules/sale:default
details: https://hg.tryton.org/modules/sale?cmd=changeset&node=e646c3af990e
description:
        Support empty list price on product

        issue10244
        review350341002
diffstat:

 product.py |  23 ++++++++++++-----------
 sale.py    |   2 +-
 2 files changed, 13 insertions(+), 12 deletions(-)

diffs (49 lines):

diff -r 488f3c86d7bb -r e646c3af990e product.py
--- a/product.py        Sat Sep 04 19:30:02 2021 +0200
+++ b/product.py        Mon Sep 13 23:29:57 2021 +0200
@@ -144,21 +144,22 @@
         user = User(Transaction().user)
 
         for product in products:
-            prices[product.id] = product._get_sale_unit_price(
-                quantity=quantity)
-            if uom and product.default_uom.category == uom.category:
-                prices[product.id] = Uom.compute_price(
-                    product.default_uom, prices[product.id], uom)
-            else:
-                prices[product.id] = Uom.compute_price(
-                    product.default_uom, prices[product.id], product.sale_uom)
-            if currency and user.company:
+            unit_price = product._get_sale_unit_price(quantity=quantity)
+            if unit_price is not None:
+                if uom and product.default_uom.category == uom.category:
+                    unit_price = Uom.compute_price(
+                        product.default_uom, unit_price, uom)
+                else:
+                    unit_price = Uom.compute_price(
+                        product.default_uom, unit_price, product.sale_uom)
+            if currency and user.company and unit_price is not None:
                 if user.company.currency != currency:
                     date = Transaction().context.get('sale_date') or today
                     with Transaction().set_context(date=date):
-                        prices[product.id] = Currency.compute(
-                            user.company.currency, prices[product.id],
+                        unit_price = Currency.compute(
+                            user.company.currency, unit_price,
                             currency, round=False)
+            prices[product.id] = unit_price
         return prices
 
     @property
diff -r 488f3c86d7bb -r e646c3af990e sale.py
--- a/sale.py   Sat Sep 04 19:30:02 2021 +0200
+++ b/sale.py   Mon Sep 13 23:29:57 2021 +0200
@@ -1310,7 +1310,7 @@
                 self._get_context_sale_price()):
             unit_price = Product.get_sale_price([self.product],
                 self.quantity or 0)[self.product.id]
-            if unit_price:
+            if unit_price is not None:
                 unit_price = round_price(unit_price)
             return unit_price
 

Reply via email to