changeset e52eb21eb67b in modules/carrier:6.0
details: https://hg.tryton.org/modules/carrier?cmd=changeset&node=e52eb21eb67b
description:
Use the instance context to get carrier prices
issue10666
review358661002
(grafted from 95bb2b6d9ef0a5cc2d81c4951bb16099ed666bd9)
diffstat:
carrier.py | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diffs (34 lines):
diff -r 9e9072d3f5a4 -r e52eb21eb67b carrier.py
--- a/carrier.py Thu Aug 05 23:50:14 2021 +0200
+++ b/carrier.py Fri Aug 27 08:48:34 2021 +0200
@@ -44,18 +44,24 @@
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