1
from client import client
2
from pprint import pprint
6
po_ids_to_cancel = c.search(
9
('state', '!=', 'cancel'),
10
('origin', '=', 'OP/02153')
14
for po_id_to_cancel in po_ids_to_cancel:
15
po_rec_to_cancel = c.fetch('mrp.production',po_id_to_cancel,['name','picking_id'])
16
print "Cancelling:", po_rec_to_cancel['id']
18
# First we need to ensure that the Packing List has been cancelled
19
if po_rec_to_cancel['picking_id']:
20
picking_id_to_cancel = po_rec_to_cancel['picking_id'][0]
21
picking_rec_to_cancel = c.fetch('stock.picking',picking_id_to_cancel,['state'])
22
if picking_rec_to_cancel['state'] == 'confirmed': # then we need to cancel the pick
31
# Then finally we can cancel the Production Order