[FIX] Stock : Fixed the problem suggested by Buildbot
[odoo/odoo.git] / addons / stock / wizard / stock_split_move.py
index f3e72bf..aa7e4c1 100644 (file)
@@ -25,7 +25,7 @@ class stock_split_move_line(osv.osv_memory):
     _name = 'stock.move.line.split'
     _description = "Split Moves"
     
-    def default_get(self, cr, uid, fields, context):
+    def default_get(self, cr, uid, fields, context=None):
         """ To get default values for the object.
          @param self: The object pointer.
          @param cr: A database cursor
@@ -34,6 +34,8 @@ class stock_split_move_line(osv.osv_memory):
          @param context: A standard dictionary 
          @return: A dictionary which of fields with values. 
         """ 
+        if context is None:
+            context = {}
         res = super(stock_split_move_line, self).default_get(cr, uid, fields, context=context)
         record_id = context and context.get('active_id', False) or False
         pick_obj = self.pool.get('stock.picking')
@@ -90,7 +92,7 @@ class stock_split_move_line(osv.osv_memory):
         res['arch'] = '\n'.join(arch_lst)
         return res
     
-    def split_lines(self, cr, uid, ids, context):
+    def split_lines(self, cr, uid, ids, context=None):
         """ Splits moves in quantity given in the wizard.
          @param self: The object pointer.
          @param cr: A database cursor
@@ -99,13 +101,14 @@ class stock_split_move_line(osv.osv_memory):
          @param context: A standard dictionary 
          @return: A dictionary which of fields with values. 
         """ 
+        if context is None:
+            context = {}
         move_obj = self.pool.get('stock.move')
         record_id = context and context.get('active_id', False) or False
         pick_obj = self.pool.get('stock.picking')
         pick = pick_obj.browse(cr, uid, record_id, context=context)
         data = self.read(cr, uid, ids[0])
-        move_ids = [m.id for m in [line for line in pick.move_lines]]
-        for move in move_obj.browse(cr, uid, move_ids, context=context):
+        for move in pick.move_lines:
             quantity = data['move%s' % move.id]
             if 0 < quantity < move.product_qty:
                 new_qty = move.product_qty - quantity
@@ -113,7 +116,7 @@ class stock_split_move_line(osv.osv_memory):
                 new_obj = move_obj.copy(cr, uid, move.id, {'product_qty' : new_qty, 'product_uos_qty': new_uos_qty, 'state':move.state})
                 uos_qty = quantity / move.product_qty * move.product_uos_qty
                 move_obj.write(cr, uid, [move.id], {'product_qty' : quantity, 'product_uos_qty': uos_qty})
-        return {}
+        return {'type': 'ir.actions.act_window_close'}
     
 stock_split_move_line()