fixed bug : when all stock move lines are cancelled, picking should be cancel

bzr revid: hmo@tinyerp.com-20081226075200-kjj1lrq2kk5znh7w
This commit is contained in:
Harry (Open ERP) 2008-12-26 13:22:00 +05:30
parent e82cf76be7
commit 77a450b627
1 changed files with 14 additions and 12 deletions

View File

@ -1062,20 +1062,22 @@ class stock_move(osv.osv):
if move.state in ('confirmed','waiting','assigned','draft'):
if move.picking_id:
pickings[move.picking_id.id] = True
if move.move_dest_id and move.move_dest_id.state=='waiting':
self.write(cr, uid, [move.move_dest_id.id], {'state':'assigned'})
if move.move_dest_id.picking_id:
wf_service = netsvc.LocalService("workflow")
wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr)
if move.move_dest_id and move.move_dest_id.state=='waiting':
self.write(cr, uid, [move.move_dest_id.id], {'state':'assigned'})
if move.move_dest_id.picking_id:
wf_service = netsvc.LocalService("workflow")
wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr)
self.write(cr, uid, ids, {'state':'cancel', 'move_dest_id': False})
#for pick_id in pickings:
# wf_service = netsvc.LocalService("workflow")
# wf_service.trg_validate(uid, 'stock.picking', pick_id, 'button_cancel', cr)
#ids2 = []
#for res in self.read(cr, uid, ids, ['move_dest_id']):
# if res['move_dest_id']:
# ids2.append(res['move_dest_id'][0])
for pick in self.pool.get('stock.picking').browse(cr,uid,pickings.keys()):
cancel=False
for move in pick.move_lines:
if move.state=='cancel':
cancel=True
if move.state!='cancel':
cancel=False
if cancel:
self.pool.get('stock.picking').write(cr,uid,[pick.id],{'state':'cancel'})
wf_service = netsvc.LocalService("workflow")
for id in ids: