[FIX] stock: action_consume was using wrong quantity field
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>
Wed, 25 Sep 2013 12:50:39 +0000 (14:50 +0200)
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>
Wed, 25 Sep 2013 12:50:39 +0000 (14:50 +0200)
bzr revid: qdp-launchpad@openerp.com-20130925125039-tb8e6qfxyohrk72f

addons/mrp/stock.py
addons/stock/stock.py

index 2e6e78c..b2b248c 100644 (file)
@@ -84,27 +84,27 @@ class StockMove(osv.osv):
                     'move_id': mid,
                 })
                 procurement_obj.signal_button_confirm(cr, uid, [proc_id])
-                
+
             move_obj.write(cr, uid, [move.id], {
-                'location_dest_id': move.location_id.id, # dummy move for the kit
+                'location_dest_id': move.location_id.id,  # dummy move for the kit
                 'picking_id': False,
                 'state': 'confirmed'
             })
-            procurement_ids = procurement_obj.search(cr, uid, [('move_id','=',move.id)], context)
+            procurement_ids = procurement_obj.search(cr, uid, [('move_id', '=', move.id)], context)
             procurement_obj.signal_button_confirm(cr, uid, procurement_ids)
             procurement_obj.signal_button_wait_done(cr, uid, procurement_ids)
         return processed_ids
-    
+
     def action_consume(self, cr, uid, ids, product_qty, location_id=False, context=None):
         """ Consumed product with specific quatity from specific source location.
         @param product_qty: Consumed product quantity
         @param location_id: Source location
         @return: Consumed lines
-        """       
+        """
         res = []
         production_obj = self.pool.get('mrp.production')
-        for move in self.browse(cr, uid, ids):
-            move.action_confirm(context)
+        for move in self.browse(cr, uid, ids, context=context):
+            self.action_confirm(cr, uid, [move.id], context=context)
             new_moves = super(StockMove, self).action_consume(cr, uid, [move.id], product_qty, location_id, context=context)
             production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
             for prod in production_obj.browse(cr, uid, production_ids, context=context):
@@ -118,13 +118,13 @@ class StockMove(osv.osv):
                 production_obj.write(cr, uid, production_ids, {'move_lines': [(4, new_move)]})
                 res.append(new_move)
         return res
-    
+
     def action_scrap(self, cr, uid, ids, product_qty, location_id, context=None):
         """ Move the scrap/damaged product into scrap location
         @param product_qty: Scraped product quantity
         @param location_id: Scrap location
         @return: Scraped lines
-        """  
+        """
         res = []
         production_obj = self.pool.get('mrp.production')
         for move in self.browse(cr, uid, ids, context=context):
index 4bee5e1..79f18e2 100644 (file)
@@ -1768,7 +1768,7 @@ class stock_move(osv.osv):
             uos_qty = quantity / move_qty * move.product_uos_qty
             if quantity_rest > 0:
                 default_val = {
-                    'product_qty': quantity,
+                    'product_uom_qty': quantity,
                     'product_uos_qty': uos_qty,
                     'state': move.state,
                     'location_id': location_id or move.location_id.id,
@@ -1776,7 +1776,7 @@ class stock_move(osv.osv):
                 current_move = self.copy(cr, uid, move.id, default_val)
                 res += [current_move]
                 update_val = {}
-                update_val['product_qty'] = quantity_rest
+                update_val['product_uom_qty'] = quantity_rest
                 update_val['product_uos_qty'] = uos_qty_rest
                 self.write(cr, uid, [move.id], update_val)
 
@@ -1785,7 +1785,7 @@ class stock_move(osv.osv):
                 uos_qty_rest =  uos_qty
                 res += [move.id]
                 update_val = {
-                        'product_qty' : quantity_rest,
+                        'product_uom_qty' : quantity_rest,
                         'product_uos_qty' : uos_qty_rest,
                         'location_id': location_id or move.location_id.id,
                 }