Get currency from line to calculate cost_price

Allow compability to sale_line_standalone
This commit is contained in:
Raimon Esteve 2022-11-24 14:30:57 +01:00
parent 329f225650
commit 42770e9503
1 changed files with 7 additions and 4 deletions

11
sale.py
View File

@ -109,16 +109,19 @@ class SaleLine(metaclass=PoolMeta):
def default_cost_price():
return _ZERO
@fields.depends('product')
@fields.depends('product', 'currency')
def on_change_product(self):
Currency = Pool().get('currency.currency')
super(SaleLine, self).on_change_product()
if self.product:
cost_price = Currency.compute(
self.sale.company.currency, self.product.cost_price,
self.sale.currency, round=False)
if self.currency:
cost_price = Currency.compute(
self.currency, self.product.cost_price,
self.sale.currency, round=False)
else:
cost_price = self.product.cost_price
self.cost_price = cost_price
@fields.depends('type', 'quantity', 'cost_price', '_parent_sale.currency',