Convert cost_price to sale currency

In case company has different currency that the sale,
cost_price require to convert the currency
#072156
This commit is contained in:
Raimon Esteve 2022-11-24 12:24:09 +01:00
parent ac6cc708ba
commit 329f225650
1 changed files with 7 additions and 1 deletions

View File

@ -111,9 +111,15 @@ class SaleLine(metaclass=PoolMeta):
@fields.depends('product')
def on_change_product(self):
Currency = Pool().get('currency.currency')
super(SaleLine, self).on_change_product()
if self.product:
self.cost_price = self.product.cost_price
cost_price = Currency.compute(
self.sale.company.currency, self.product.cost_price,
self.sale.currency, round=False)
self.cost_price = cost_price
@fields.depends('type', 'quantity', 'cost_price', '_parent_sale.currency',
'_parent_sale.lines', methods=['on_change_with_amount'])