changeset 0543457ef983 in modules/carrier_percentage:default
details: 
https://hg.tryton.org/modules/carrier_percentage?cmd=changeset;node=0543457ef983
description:
        Use move's origin to get the unit price

        issue9486
        review321851002
diffstat:

 stock.py |  14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diffs (24 lines):

diff -r 092ca50dc28c -r 0543457ef983 stock.py
--- a/stock.py  Thu Jul 09 10:21:06 2020 +0100
+++ b/stock.py  Fri Jul 24 10:01:21 2020 +0200
@@ -13,12 +13,14 @@
 
     amount = 0
     for line in lines or []:
-        unit_price = getattr(line, 'unit_price',
-            Move.default_unit_price() if hasattr(Move, 'default_unit_price')
-            else Decimal(0))
-        currency = getattr(line, 'currency',
-            Move.default_currency() if hasattr(Move, 'default_currency')
-            else None)
+        unit_price = getattr(line, 'unit_price', None)
+        currency = getattr(line, 'currency', None)
+        if unit_price is None and isinstance(line.origin, Move):
+            unit_price = line.origin.unit_price
+            currency = line.origin.currency
+        if unit_price is None:
+            unit_price = Decimal(0)
+            currency = None
         if currency:
             unit_price = Currency.compute(currency, unit_price,
                 company.currency, round=False)

Reply via email to