Mayur Maheshwari(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-953324-mma into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #953324 in OpenERP Addons: "stock.move and stock.inventory.line no 
_check_UOM"
  https://bugs.launchpad.net/openobject-addons/+bug/953324

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-953324-mma/+merge/97197

Hello,

       stock: I Have added check_uom constraints in stock.move and 
stock.inventory.line Object


Thanks.
mma
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-953324-mma/+merge/97197
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-953324-mma.
=== modified file 'stock/stock.py'
--- stock/stock.py	2012-02-28 14:08:16 +0000
+++ stock/stock.py	2012-03-13 11:35:23 +0000
@@ -1610,6 +1610,13 @@
             if (record.state=='done') and (record.location_dest_id.usage == 'view' or record.location_id.usage == 'view'):
                 return False
         return True
+    
+    def _check_uom(self, cr, uid, ids, context=None):
+        for move in self.browse(cr, uid, ids, context=context):
+            product = self.pool.get('product.product').browse(cr, uid, move.product_id.id, context=context)
+            if product.uom_id.category_id.id != move.product_uom.category_id.id:
+                return False
+        return True
 
     _constraints = [
         (_check_tracking,
@@ -1617,6 +1624,8 @@
             ['prodlot_id']),
         (_check_location, 'You can not move products from or to a location of the type view.',
             ['location_id','location_dest_id']),
+        (_check_uom, 'UoM categories Mismatch: The move UOM and the product UOM must be in the same category.', 
+            ['product_uom']),
         (_check_product_lot,
             'You try to assign a lot which is not from the same product',
             ['prodlot_id'])]
@@ -2749,6 +2758,17 @@
         'state': fields.related('inventory_id','state',type='char',string='State',readonly=True),
     }
 
+    def _check_uom(self, cr, uid, ids, context=None):
+        for line in self.browse(cr, uid, ids, context=context):
+            product = self.pool.get('product.product').browse(cr, uid, line.product_id.id, context=context)
+            if product.uom_id.category_id.id != line.product_uom.category_id.id:
+                return False
+        return True
+
+    _constraints = [
+        (_check_uom, 'UoM categories Mismatch: The line UOM and the product UOM must be in the same category.', ['product_uom']),
+    ]
+
     def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False, to_date=False):
         """ Changes UoM and name if product_id changes.
         @param location_id: Location id

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to