~zaber/openobject-client/main

« back to all changes in this revision

Viewing changes to scripts/production_order_cancel_by_origin.py

  • Committer: donkirkby+launpd at gmail
  • Date: 2013-02-12 23:13:46 UTC
  • Revision ID: donkirkby+launpd@gmail.com-20130212231346-mewt8dw2q6p9kyy3
[IMP] Remove some utility scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from client import client
2
 
from pprint import pprint
3
 
 
4
 
c = client()
5
 
 
6
 
po_ids_to_cancel  = c.search(
7
 
      'mrp.production',
8
 
      [ 
9
 
        ('state',  '!=',   'cancel'),
10
 
        ('origin', '=',    'OP/02153') 
11
 
      ]
12
 
      )
13
 
 
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']
17
 
 
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
23
 
            c.sock.exec_workflow(
24
 
                c.dbname,
25
 
                c.user_id,
26
 
                c.pwd,
27
 
                'stock.picking',
28
 
                'button_cancel',
29
 
                picking_id_to_cancel)
30
 
 
31
 
    # Then finally we can cancel the Production Order
32
 
    c.sock.exec_workflow(
33
 
        c.dbname,
34
 
        c.user_id,
35
 
        c.pwd,
36
 
        'mrp.production',
37
 
        'button_cancel',
38
 
        po_id_to_cancel)
39
 
 
40