Atik Agewan(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-707287-aag into 
lp:openobject-addons.

Requested reviews:
  Rucha (Open ERP) (rpa-openerp)
  qdp (OpenERP) (qdp)
  Atik Agewan(OpenERP) (aag-openerp)
Related bugs:
  Bug #707287 in OpenERP Addons: "Manufacturing orders broken UOM"
  https://bugs.launchpad.net/openobject-addons/+bug/707287

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-707287-aag/+merge/80213


 Hello,

  Product :User can not change the existing UOM category ,Old Uom and New Uom 
category should be same.

 Thanks,
  Atik
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-707287-aag/+merge/80213
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-707287-aag.
=== modified file 'product/product.py'
--- product/product.py	2011-10-11 14:03:35 +0000
+++ product/product.py	2011-11-04 09:58:25 +0000
@@ -166,6 +166,13 @@
         if value == 'reference':
             return {'value': {'factor': 1, 'factor_inv': 1}}
         return {}
+    
+    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()
 
@@ -328,6 +335,15 @@
             return {'value': {'uom_po_id': uom_id}}
         return False
 
+    def write(self, cr, uid, ids, vals, context=None):
+        if 'uom_po_id' in vals:
+            new_uom = self.pool.get('product.uom').browse(cr, uid, vals['uom_po_id'], context=context)
+            for product in self.browse(cr, uid, ids, context=context):
+                old_uom = product.uom_po_id
+                if old_uom.category_id.id != new_uom.category_id.id:
+                    raise osv.except_osv(_('UoM categories Mismatch!'), _("New UoM '%s' must belongs to same UoM category '%s' as of old UoM '%s'.") % (new_uom.name, old_uom.category_id.name, old_uom.name,))
+        return super(product_template, self).write(cr, uid, ids, vals, context=context)
+
     _defaults = {
         'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'product.template', context=c),
         'list_price': lambda *a: 1,

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : openerp-dev-gtk@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to