diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index bb23cd3a10e..7a3861585dc 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -1089,9 +1089,8 @@ class SaleOrderLine(models.Model): return product.with_context(pricelist=self.order_id.pricelist_id.id).price final_price, rule_id = self.order_id.pricelist_id.get_product_price_rule(self.product_id, self.product_uom_qty or 1.0, self.order_id.partner_id) context_partner = dict(self.env.context, partner_id=self.order_id.partner_id.id, date=self.order_id.date_order) - base_price, currency_id = self.with_context(context_partner)._get_real_price_currency(self.product_id, rule_id, self.product_uom_qty, self.product_uom, self.order_id.pricelist_id.id) - if currency_id != self.order_id.pricelist_id.currency_id.id: - currency = self.env['res.currency'].browse(currency_id) + base_price, currency = self.with_context(context_partner)._get_real_price_currency(self.product_id, rule_id, self.product_uom_qty, self.product_uom, self.order_id.pricelist_id.id) + if currency != self.order_id.pricelist_id.currency_id: base_price = currency._convert( base_price, self.order_id.pricelist_id.currency_id, self.order_id.company_id, self.order_id.date_order or fields.Date.today()) @@ -1253,12 +1252,11 @@ class SaleOrderLine(models.Model): pricelist_context = dict(context_partner, uom=self.product_uom.id) price, rule_id = self.order_id.pricelist_id.with_context(pricelist_context).get_product_price_rule(self.product_id, self.product_uom_qty or 1.0, self.order_id.partner_id) - new_list_price, currency_id = self.with_context(context_partner)._get_real_price_currency(self.product_id, rule_id, self.product_uom_qty, self.product_uom, self.order_id.pricelist_id.id) + new_list_price, currency = self.with_context(context_partner)._get_real_price_currency(self.product_id, rule_id, self.product_uom_qty, self.product_uom, self.order_id.pricelist_id.id) if new_list_price != 0: - if self.order_id.pricelist_id.currency_id.id != currency_id: + if self.order_id.pricelist_id.currency_id != currency: # we need new_list_price in the same currency as price, which is in the SO's pricelist's currency - currency = self.env['res.currency'].browse(currency_id) new_list_price = currency._convert( new_list_price, self.order_id.pricelist_id.currency_id, self.order_id.company_id, self.order_id.date_order or fields.Date.today())