From e8c3375bb130a702b5e10f21774ff16a0c31b77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 27 Aug 2021 08:48:34 +0200 Subject: [PATCH] Use the instance context to get carrier prices issue10666 review358661002 --- carrier.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/carrier.py b/carrier.py index 0467186929..ac52ae8002 100644 --- a/carrier.py +++ b/carrier.py @@ -44,18 +44,24 @@ class Carrier(DeactivableMixin, ModelSQL, ModelView): def get_sale_price(self): 'Compute carrier sale price with currency' - User = Pool().get('res.user') + pool = Pool() + Company = pool.get('company.company') if self.carrier_cost_method == 'product': - user = User(Transaction().user) - return self.carrier_product.list_price, user.company.currency.id + list_price = self.carrier_product.list_price_used + if list_price is not None: + company = Company(self.carrier_product._context['company']) + return list_price, company.currency.id return 0, None def get_purchase_price(self): 'Compute carrier purchase price with currency' - User = Pool().get('res.user') + pool = Pool() + Company = pool.get('company.company') if self.carrier_cost_method == 'product': - user = User(Transaction().user) - return self.carrier_product.cost_price, user.company.currency.id + cost_price = self.carrier_product.cost_price + if cost_price is not None: + company = Company(self.carrier_product._context['company']) + return cost_price, company.currency.id return 0, None @classmethod