From 42770e9503ef1802b841b20afb8a37be8e89281d Mon Sep 17 00:00:00 2001 From: Raimon Esteve Date: Thu, 24 Nov 2022 14:30:57 +0100 Subject: [PATCH] Get currency from line to calculate cost_price Allow compability to sale_line_standalone --- sale.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sale.py b/sale.py index 53dec52..a4328c8 100644 --- a/sale.py +++ b/sale.py @@ -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',