[FIX] stock: partial deliveries switch on delivered picking
Users don't care for the backorder picking precisely because they can't process it, whereas they may have to do some more things on the picking they processed: invoice it, print delivery orders or transportation stickers.. Refresh the browse record after changing the name to avoid the need to rebrowse. Fixes #1372
This commit is contained in:
parent
f9da53743f
commit
dd4d72d710
|
@ -1305,6 +1305,7 @@ class stock_picking(osv.osv):
|
|||
{'name': sequence_obj.get(cr, uid,
|
||||
'stock.picking.%s'%(pick.type)),
|
||||
})
|
||||
pick.refresh()
|
||||
new_picking = self.copy(cr, uid, pick.id,
|
||||
{
|
||||
'name': new_picking_name,
|
||||
|
@ -1362,9 +1363,8 @@ class stock_picking(osv.osv):
|
|||
self.action_move(cr, uid, [new_picking], context=context)
|
||||
wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_done', cr)
|
||||
wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
|
||||
delivered_pack_id = pick.id
|
||||
back_order_name = self.browse(cr, uid, delivered_pack_id, context=context).name
|
||||
self.message_post(cr, uid, new_picking, body=_("Back order <em>%s</em> has been <b>created</b>.") % (back_order_name), context=context)
|
||||
delivered_pack_id = new_picking
|
||||
self.message_post(cr, uid, new_picking, body=_("Back order <em>%s</em> has been <b>created</b>.") % (pick.name), context=context)
|
||||
else:
|
||||
self.action_move(cr, uid, [pick.id], context=context)
|
||||
wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_done', cr)
|
||||
|
|
|
@ -156,6 +156,8 @@ class stock_partial_picking(osv.osv_memory):
|
|||
return partial_move
|
||||
|
||||
def do_partial(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
assert len(ids) == 1, 'Partial picking processing may only be done one at a time.'
|
||||
stock_picking = self.pool.get('stock.picking')
|
||||
stock_move = self.pool.get('stock.move')
|
||||
|
@ -211,7 +213,19 @@ class stock_partial_picking(osv.osv_memory):
|
|||
if (picking_type == 'in') and (wizard_line.product_id.cost_method == 'average'):
|
||||
partial_data['move%s' % (wizard_line.move_id.id)].update(product_price=wizard_line.cost,
|
||||
product_currency=wizard_line.currency.id)
|
||||
stock_picking.do_partial(cr, uid, [partial.picking_id.id], partial_data, context=context)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
# Do the partial delivery and open the picking that was delivered
|
||||
# We don't need to find which view is required, stock.picking does it.
|
||||
done = stock_picking.do_partial(
|
||||
cr, uid, [partial.picking_id.id], partial_data, context=context)
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': context.get('active_model', 'stock.picking'),
|
||||
'name': _('Partial Delivery'),
|
||||
'res_id': done[partial.picking_id.id]['delivered_picking'],
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form,tree,calendar',
|
||||
'context': context,
|
||||
}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
Loading…
Reference in New Issue