diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 109c7c5024b..5291bf28703 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -657,20 +657,21 @@ class stock_picking(osv.osv): 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.picking', context=c) } def action_process(self, cr, uid, ids, context=None): + if context is None: context = {} + partial_id = self.pool.get("stock.partial.picking").create( + cr, uid, {}, context=dict(context, active_ids=ids)) return { 'name':_("Products to Process"), 'view_mode': 'form', 'view_id': False, 'view_type': 'form', 'res_model': 'stock.partial.picking', + 'res_id': partial_id, 'type': 'ir.actions.act_window', 'nodestroy': True, 'target': 'new', 'domain': '[]', - 'context': { - 'active_id': ids[0], - 'active_ids':ids - } + 'context': dict(context, active_ids=ids) } def copy(self, cr, uid, id, default=None, context=None): @@ -757,25 +758,14 @@ class stock_picking(osv.osv): """ Validates picking directly from draft state. @return: True """ - if context is None: - context = {} wf_service = netsvc.LocalService("workflow") self.draft_force_assign(cr, uid, ids) for pick in self.browse(cr, uid, ids, context=context): move_ids = [x.id for x in pick.move_lines] self.pool.get('stock.move').force_assign(cr, uid, move_ids) wf_service.trg_write(uid, 'stock.picking', pick.id, cr) - context.update({'active_ids':ids}) - return { - 'name': 'Make Picking', - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'stock.partial.picking', - 'type': 'ir.actions.act_window', - 'target': 'new', - 'nodestroy': True, - 'context':context - } + return self.action_process( + cr, uid, ids, context=context) def cancel_assign(self, cr, uid, ids, *args): """ Cancels picking and moves. @return: True