diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index d363275b7fa..64284f7c0c2 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -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 %s has been created.") % (back_order_name), context=context)
+ delivered_pack_id = new_picking
+ self.message_post(cr, uid, new_picking, body=_("Back order %s has been created.") % (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)
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
index ceedb682ed8..7358855924d 100644
--- a/addons/stock/wizard/stock_partial_picking.py
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -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: