changeset dc6d71a65a74 in modules/carrier_percentage:5.0
details: 
https://hg.tryton.org/modules/carrier_percentage?cmd=changeset&node=dc6d71a65a74
description:
        Do not compute price if no currency is set

        issue11684
        review435831003
        (grafted from 04a83e8ba9b4b224ab362a589f23dd7526e323dd)
diffstat:

 carrier.py |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (30 lines):

diff -r 80153e3346e2 -r dc6d71a65a74 carrier.py
--- a/carrier.py        Thu Jun 17 21:53:26 2021 +0200
+++ b/carrier.py        Sun Sep 25 20:21:45 2022 +0200
@@ -30,8 +30,6 @@
         Currency = Pool().get('currency.currency')
 
         price = amount * self.percentage / Decimal(100)
-        if not currency_id:
-            return price, currency_id
         currency = Currency(currency_id)
         return currency.round(price), currency_id
 
@@ -40,7 +38,8 @@
         if self.carrier_cost_method == 'percentage':
             amount = Transaction().context.get('amount', Decimal(0))
             currency_id = Transaction().context.get('currency', currency_id)
-            return self.compute_percentage(amount, currency_id)
+            if currency_id is not None:
+                return self.compute_percentage(amount, currency_id)
         return price, currency_id
 
     def get_purchase_price(self):
@@ -48,5 +47,6 @@
         if self.carrier_cost_method == 'percentage':
             amount = Transaction().context.get('amount', Decimal(0))
             currency_id = Transaction().context.get('currency', currency_id)
-            return self.compute_percentage(amount, currency_id)
+            if currency_id is not None:
+                return self.compute_percentage(amount, currency_id)
         return price, currency_id

Reply via email to