From e42e6d4b0d71fc527a7d650add07421541b1723d Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 19 Nov 2015 12:13:53 +0100 Subject: [PATCH] [FIX] website_quote: old api on_change_product_id The old api on_change_product_id function in model 'sale.order.option' doesn't receive the order_id to compute correctly the price unit for suggested products. The new api _onchange_product_id function has exactly the same logic as on_change_product_id and this function receives the order_id. Then the new one can replace the old one. But to keep the compatibility with partners who overwrite this old function, it is kept in the code. This bug was introduced by 5047f4e, this commit defined the product_uom_change function which called on_change_product_id. This commit was applied in saas-6. The onchange calls in the views have be removed because all the new api onchange are called even if they were still there. opw:656494 --- addons/website_quote/models/order.py | 9 ++++++++- addons/website_quote/views/website_quotation_backend.xml | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/website_quote/models/order.py b/addons/website_quote/models/order.py index de669c00858..82c108fe112 100644 --- a/addons/website_quote/models/order.py +++ b/addons/website_quote/models/order.py @@ -405,14 +405,17 @@ class sale_order_option(osv.osv): domain = {'uom_id': [('category_id', '=', product_obj.uom_id.category_id.id)]} return {'value': vals, 'domain': domain} + # TODO master: to remove, replaced by onchange of the new api def product_uom_change(self, cr, uid, ids, product, uom_id, context=None): context = context or {} if not uom_id: return {'value': {'price_unit': 0.0, 'uom_id': False}} return self.on_change_product_id(cr, uid, ids, product, uom_id=uom_id, context=context) - @api.onchange('product_id') + @api.onchange('product_id', 'uom_id') def _onchange_product_id(self): + if not self.product_id: + return product = self.product_id.with_context(lang=self.order_id.partner_id.lang) self.price_unit = product.list_price self.website_description = product.quote_description or product.website_description @@ -424,6 +427,10 @@ class sale_order_option(osv.osv): partner_id = self.order_id.partner_id.id pricelist = self.order_id.pricelist_id.id self.price_unit = self.order_id.pricelist_id.price_get(product.id, self.quantity, partner_id)[pricelist] + if self.uom_id and self.uom_id != self.product_id.uom_id: + self.price_unit = self.product_id.uom_id._compute_price(self.price_unit, self.uom_id.id) + domain = {'uom_id': [('category_id', '=', self.product_id.uom_id.category_id.id)]} + return {'domain': domain} class product_template(osv.Model): diff --git a/addons/website_quote/views/website_quotation_backend.xml b/addons/website_quote/views/website_quotation_backend.xml index c2ff76c36de..d02bb06f404 100644 --- a/addons/website_quote/views/website_quotation_backend.xml +++ b/addons/website_quote/views/website_quotation_backend.xml @@ -34,7 +34,7 @@ - + @@ -118,10 +118,10 @@ - + - +