2 I first create a warehouse with pick-pack-ship and receipt in 2 steps
4 !record {model: stock.warehouse, id: wh_pps}:
5 name: WareHouse PickPackShip
7 reception_steps: 'two_steps'
8 delivery_steps: 'pick_pack_ship'
10 Next I create a new product in this warehouse
12 !record {model: product.product, id: product_mto}:
15 uom_id: product.product_uom_unit
16 uom_po_id: product.product_uom_unit
19 name: base.res_partner_2
23 Set routes on product to be MTO adn Buy
25 !python {model: product.product}: |
26 route_warehouse0_buy = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock.warehouse0')).buy_pull_id.route_id.id
27 route_warehouse0_mto = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock.warehouse0')).mto_pull_id.route_id.id
28 self.write(cr, uid, ref('product_mto'), { 'route_ids': [(6, 0, [route_warehouse0_mto,route_warehouse0_buy])]}, context=context )
30 Create a sales order with a line of 5 "My Product".
32 !record {model: sale.order, id: sale_order_product_mto}:
33 partner_id: base.res_partner_3
34 note: Create Sales order
37 - product_id: product_mto
40 Confirm the sale order
42 !workflow {model: sale.order, action: order_confirm, ref: sale_order_product_mto}
46 !python {model: procurement.order}: |
47 self.run_scheduler(cr, uid)
49 Check the propagation when we cancel the main procurement
50 * Retrieve related procurements and check that there are all running
51 * Check that a purchase order is well created
52 * Cancel the main procurement
53 * Check that all procurements related and the purchase order are well cancelled
55 !python {model: procurement.order}: |
56 # Retrieve related procurement
57 so = self.pool.get('sale.order').browse(cr, uid, ref('sale_order_product_mto'))
58 procu_ids = self.search(cr, uid, [('group_id.name', '=', so.name)])
59 assert len(procu_ids)>0, 'No procurement found for sale order %s (with id: %d)' %(so.name,so.id)
61 # Check that all procurements are running
62 for procu in self.browse(cr,uid,procu_ids,context=context):
63 assert procu.state == u'running', 'Procurement with id: %d should be running but is with state : %s!' %(procu.id, procu.state)
65 # Check that one or more Purchase order
66 purchase_ids = [proc.purchase_line_id.order_id for proc in self.browse(cr, uid, procu_ids) if proc.purchase_line_id]
67 assert len(purchase_ids) > 0, 'No purchase order found !'
69 # Cancel the main procurement
70 main_procu_id = self.search(cr, uid, [('origin', '=', so.name)])
71 assert len(main_procu_id) == 1, 'Main procurement not identified !'
72 self.cancel(cr, uid, main_procu_id, context=context)
73 assert self.browse(cr, uid, main_procu_id[0]).state == u'cancel', 'Main procurement should be cancelled !'
75 # Check that all procurements related are cancelled
76 for procu in self.browse(cr, uid, procu_ids, context=context):
77 assert procu.state == u'cancel', 'Procurement %d should be cancelled but is with a state : %s!' %(procu.id, procu.state)
79 # Check that the purchase order is well cancelled
80 for po in self.pool.get('purchase.order').browse(cr, uid, [po.id for po in purchase_ids], context=context):
81 assert po.state == u'cancel', 'Purchase order %d should be cancelled but is in state : %s!' %(po.id, po.state)