From 2d207c5d5d7a56ddc63a0428507de8cd951e736b Mon Sep 17 00:00:00 2001 From: Xavier ALT Date: Tue, 9 Oct 2012 13:06:00 +0200 Subject: [PATCH] [FIX] sale/purchase: invert check - simplify forcing product's UoM only when changing 'product_id' field bzr revid: xal@openerp.com-20121009110600-0d19szr59l2a0pw4 --- addons/purchase/purchase.py | 12 ++++-------- addons/purchase/purchase_view.xml | 2 +- addons/sale/sale.py | 11 ++++------- addons/sale/sale_view.xml | 2 +- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 918cc545047..2cb8429724c 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -703,9 +703,6 @@ class purchase_order_line(osv.osv): """ onchange handler of product_uom. """ - if context is None: - context = {} - context = dict(context, uom_change=True) if not uom_id: return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or'', 'product_uom' : uom_id or False}} return self.onchange_product_id(cr, uid, ids, pricelist_id, product_id, qty, uom_id, @@ -733,10 +730,9 @@ class purchase_order_line(osv.osv): """ onchange handler of product_id. - :param dict context: 'uom_change' key in context override default onchange - behaviour which force product's UoM, allowing to - specify an 'uom_id' of the same category as product's - UoM (ex: set when called from product_uom's onchange). + :param dict context: 'force_product_uom' key in context override + default onchange behaviour to force using the UoM + defined on the provided product """ if context is None: context = {} @@ -770,7 +766,7 @@ class purchase_order_line(osv.osv): # - check that uom and product uom belong to the same category product_uom_po_id = product.uom_po_id.id - if not uom_id or not context.get('uom_change'): + if not uom_id or context.get('force_product_uom'): uom_id = product_uom_po_id if product.uom_id.category_id.id != product_uom.browse(cr, uid, uom_id, context=context).category_id.id: diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 1c936055aff..88d92af5bdd 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -359,7 +359,7 @@
- + diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 064ae7d2b2e..7d35ec7918b 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1192,11 +1192,9 @@ class sale_order_line(osv.osv): """ onchange handler for product_id. - :param dict context: 'uom_change' key in context override default onchange - behaviour which force product's UoM, allowing to - specify an 'uom_id' of the same category as product's - UoM (ex: set when called from product_uom's onchange). - + :param dict context: 'force_product_uom' key in context override + default onchange behaviour to force using the UoM + defined on the provided product """ if context is None: context = {} @@ -1227,7 +1225,7 @@ class sale_order_line(osv.osv): uom2 = False if uom: uom2 = product_uom_obj.browse(cr, uid, uom, context=context) - if product_obj.uom_id.category_id.id != uom2.category_id.id or not context.get('uom_change',False): + if product_obj.uom_id.category_id.id != uom2.category_id.id or context.get('force_product_uom'): uom = False uom2 = False if uos: @@ -1321,7 +1319,6 @@ class sale_order_line(osv.osv): if context is None: context = {} lang = lang or context.get('lang',False) - context = dict(context, uom_change=True) res = self.product_id_change(cursor, user, ids, pricelist, product, qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id, lang=lang, update_tax=update_tax, diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 90d3838f5a0..9f109286205 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -128,7 +128,7 @@