[FIX] stock: fix problem of context to open partial delivery form

bzr revid: hmo@tinyerp.com-20120920050524-7q5swtdm54ry2fkr
This commit is contained in:
Harry (OpenERP) 2012-09-20 10:35:24 +05:30
parent 29e288d2a5
commit 14a1819fa7
2 changed files with 8 additions and 11 deletions

View File

@ -673,6 +673,13 @@ class stock_picking(osv.osv):
]
def action_process(self, cr, uid, ids, context=None):
if context is None:
context = {}
context.update({
'active_model': self._name,
'active_ids': ids,
'active_id': len(ids) and ids[0] or False
})
return {
'view_type': 'form',
'view_mode': 'form',

View File

@ -99,21 +99,11 @@ class stock_partial_picking(osv.osv_memory):
res = super(stock_partial_picking, self).default_get(cr, uid, fields, context=context)
picking_ids = context.get('active_ids', [])
active_model = context.get('active_model')
if active_model == 'purchase.order':
for purchase_order in self.pool.get('purchase.order').browse(cr, uid, picking_ids, context=context):
picking_ids = [picking_id.id for picking_id in purchase_order.picking_ids if picking_id.type == 'in' and picking_id.state not in ('done', 'cancel')]
elif active_model == 'sale.order':
for sale_order in self.pool.get('sale.order').browse(cr, uid, picking_ids, context=context):
picking_ids = [picking.id for picking in sale_order.picking_ids if picking_id.type == 'out' and picking_id.state not in ('done', 'cancel')]
if not picking_ids or len(picking_ids) != 1:
# Partial Picking Processing may only be done for one picking at a time
return res
# The check about active_model is there in case the client mismatched the context during propagation of it
# (already seen in previous bug where context passed was containing ir.ui.menu as active_model and the menu
# ID as active_id). Though this should be fixed in clients now, this place is sensitive enough to ensure the
# consistancy of the context.
assert active_model in ('stock.picking', 'stock.picking.in', 'stock.picking.out', 'purchase.order', 'sale.order'), 'Bad context propagation'
assert active_model in ('stock.picking', 'stock.picking.in', 'stock.picking.out'), 'Bad context propagation'
picking_id, = picking_ids
if 'picking_id' in fields:
res.update(picking_id=picking_id)