_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
@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')
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
@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
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()