From a7c664fb6cfce730309197fcb71bca4dc9a9084d Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Tue, 2 Feb 2016 13:17:02 +0100 Subject: [PATCH] [FIX] website_quote: handling of uoms in _onchange_product_id The condition self.uom_id != self.product_id.uom_id could actually never be met, since a few lines before you could read self.uom_id = product.product_tmpl_id.uom_id. From now on, simply check if the uom_id on the cached record is different from the one on the product and check the price using the pricelist (_compute_price does not take pricelists into account) with the wonderfully explicit with_context call. --- addons/website_quote/models/order.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/addons/website_quote/models/order.py b/addons/website_quote/models/order.py index cda5d83e275..05a58e375ae 100644 --- a/addons/website_quote/models/order.py +++ b/addons/website_quote/models/order.py @@ -414,13 +414,11 @@ class sale_order_option(osv.osv): self.name = product.name if product.description_sale: self.name += '\n' + product.description_sale - self.uom_id = product.product_tmpl_id.uom_id - if product and self.order_id.pricelist_id: + self.uom_id = self.uom_id or product.uom_id + pricelist = self.order_id.pricelist_id + if pricelist and product: 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) + self.price_unit = pricelist.with_context(uom=self.uom_id.id).price_get(product.id, self.quantity, partner_id)[pricelist.id] domain = {'uom_id': [('category_id', '=', self.product_id.uom_id.category_id.id)]} return {'domain': domain}