[IMP] mrp, stock: default uom missing value when importing from csv
authorJitendra Prajapati <jpr@openerp.com>
Thu, 19 Jun 2014 10:10:13 +0000 (15:40 +0530)
committerRichard Mathot <rim@openerp.com>
Mon, 13 Oct 2014 08:56:21 +0000 (10:56 +0200)
addons/mrp/mrp.py
addons/stock/stock.py

index 8d87dfb..a574b2b 100644 (file)
@@ -406,6 +406,14 @@ class mrp_bom_line(osv.osv):
             'You should install the mrp_byproduct module if you want to manage extra products on BoMs !'),
     ]
 
+    def create(self, cr, uid, values, context=None):
+        if context is None:
+            context = {}
+        product_obj = self.pool.get('product.product')
+        if 'product_id' in values and not 'product_uom' in values:
+            values['product_uom'] = product_obj.browse(cr, uid, values.get('product_id'), context=context).uom_id.id
+        return super(mrp_bom_line, self).create(cr, uid, values, context=context)
+
     def onchange_uom(self, cr, uid, ids, product_id, product_uom, context=None):
         res = {'value': {}}
         if not product_uom or not product_id:
@@ -594,6 +602,14 @@ class mrp_production(osv.osv):
         (_check_qty, 'Order quantity cannot be negative or zero!', ['product_qty']),
     ]
 
+    def create(self, cr, uid, values, context=None):
+        if context is None:
+            context = {}
+        product_obj = self.pool.get('product.product')
+        if 'product_id' in values and not 'product_uom' in values:
+            values['product_uom'] = product_obj.browse(cr, uid, values.get('product_id'), context=context).uom_id.id
+        return super(mrp_production, self).create(cr, uid, values, context=context)
+
     def unlink(self, cr, uid, ids, context=None):
         for production in self.browse(cr, uid, ids, context=context):
             if production.state not in ('draft', 'cancel'):
index 927476e..b5ac4cf 100644 (file)
@@ -2724,6 +2724,14 @@ class stock_inventory_line(osv.osv):
         'product_qty': 1,
     }
 
+    def create(self, cr, uid, values, context=None):
+        if context is None:
+            context = {}
+        product_obj = self.pool.get('product.product')
+        if 'product_id' in values and not 'product_uom_id' in values:
+            values['product_uom_id'] = product_obj.browse(cr, uid, values.get('product_id'), context=context).uom_id.id
+        return super(stock_inventory_line, self).create(cr, uid, values, context=context)
+
     def _resolve_inventory_line(self, cr, uid, inventory_line, context=None):
         stock_move_obj = self.pool.get('stock.move')
         diff = inventory_line.theoretical_qty - inventory_line.product_qty