From aa6badc3f89b63a12630b241fa6756d980528d06 Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Thu, 3 Nov 2011 16:15:21 +0530 Subject: [PATCH] [REF]: product: Code improvement in write() of product uom bzr revid: rpa@tinyerp.com-20111103104521-ig8yt4ize3vtci35 --- addons/product/product.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index 76a12bc35bd..5ade648cef8 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -167,16 +167,12 @@ class product_uom(osv.osv): return {'value': {'factor': 1, 'factor_inv': 1}} return {} - def write(self, cr, uid, ids, vals, context=None, update_check=True): - if context is None: - context={} - category_browse = self.browse(cr, uid,ids)[0] - old_category = category_browse.category_id - if 'category_id' in vals.keys(): - if vals['category_id'] <> old_category.id: - raise osv.except_osv(_('Warning'),_("User can not change the existing UOM category '%s' !! ") % (old_category.name,)) - res = super(product_uom, self).write(cr, uid, ids, vals, context=context) - return res + def write(self, cr, uid, ids, vals, context=None): + if 'category_id' in vals: + for uom in self.browse(cr, uid, ids, context=context): + if uom.category_id != vals['category_id']: + raise osv.except_osv(_('Warning'),_("Cannot change the category of existing UoM '%s'.") % (uom.name,)) + return super(product_uom, self).write(cr, uid, ids, vals, context=context) product_uom()