From 4a800e02a1f0a702d2d58ad7862b2c7a2fc90fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 25 Sep 2022 20:21:45 +0200 Subject: [PATCH] Do not compute price if no currency is set issue11684 review435831003 (grafted from 04a83e8ba9b4b224ab362a589f23dd7526e323dd) --HG-- branch : 6.0 --- carrier.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/carrier.py b/carrier.py index 971e4caf33..9fe34eca6e 100644 --- a/carrier.py +++ b/carrier.py @@ -28,8 +28,6 @@ class Carrier(metaclass=PoolMeta): 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 @@ -38,7 +36,8 @@ class Carrier(metaclass=PoolMeta): 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): @@ -46,5 +45,6 @@ class Carrier(metaclass=PoolMeta): 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