From c71ee8e2d2b701a36bff594a4a3ac0f7847addca Mon Sep 17 00:00:00 2001 From: jem-odoo Date: Fri, 27 Apr 2018 11:48:50 +0200 Subject: [PATCH] [FIX] sale: stop browsing recordset `currency_id` variable is a recordset, so stop browsing it again ! In the meantime, if those variable had a meaningfull name, this error would never occured ! Coming from 7a282c99655d4f154ac1808fcb8a70339dc70930 --- addons/sale/models/sale.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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())