[IMP] Maifest for Github README.md on main apps
[odoo/odoo.git] / addons / stock_dropshipping / test / cancellation_propagated.yml
1 -
2   I first create a warehouse with pick-pack-ship and receipt in 2 steps
3 -
4   !record {model: stock.warehouse, id: wh_pps}:
5     name: WareHouse PickPackShip 
6     code: whpps
7     reception_steps: 'two_steps'
8     delivery_steps: 'pick_pack_ship' 
9 -
10   Next I create a new product in this warehouse
11 -
12   !record {model: product.product, id: product_mto}:
13     name: "My Product"
14     type: product
15     uom_id: product.product_uom_unit
16     uom_po_id: product.product_uom_unit
17     seller_ids:                                                                                                                         
18       - delay: 1
19         name: base.res_partner_2
20         min_qty: 2.0
21         qty: 10.0
22 -
23   Set routes on product to be MTO adn Buy
24 -
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 )       
29 -
30   Create a sales order with a line of 5 "My Product".
31
32   !record {model: sale.order, id: sale_order_product_mto}:
33     partner_id: base.res_partner_3
34     note: Create Sales order
35     warehouse_id: wh_pps
36     order_line:
37       - product_id: product_mto
38         product_uom_qty: 5.00
39
40   Confirm the sale order
41
42   !workflow {model: sale.order, action: order_confirm, ref: sale_order_product_mto}
43 -
44   I run scheduler.
45 -
46   !python {model: procurement.order}: |
47     self.run_scheduler(cr, uid)
48
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   
54 -
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)
60     
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)
64     
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 !'
68     
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 !'
74     
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)
78
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)