[MERGE] MErged from main branch
[odoo/odoo.git] / addons / purchase_requisition / test / purchase_requisition_exclusive.yml
1 -
2   In order to test the purchase requisition module, I will do a sale order -> purchase_requisition ->
3   purchase flow and I will buy the required products at two different suppliers.
4 -
5   I start by creating a new product 'Laptop ACER', which is purchased at Asustek, in MTO,
6   with the generation of purchase requisitions.    
7 -
8   !record {model: product.product, id: product_product_laptopacer1}:
9     categ_id: product.product_category_3
10     cost_method: standard
11     list_price: 1000.0
12     mes_type: fixed
13     name: Laptop ACER1
14     procure_method: make_to_order
15     purchase_requisition: 1
16     seller_ids:
17       - delay: 1
18         name: base.res_partner_asus
19         qty: 5.0
20     supply_method: buy
21     type: product
22     uom_id: product.product_uom_unit
23     uom_po_id: product.product_uom_unit 
24
25   Then I sell 5 Laptop ACER to the customer Agrolait, sale order TEST/TENDER/0002
26
27   !record {model: sale.order, id: sale_order_testtender1}:
28     date_order: '2010-04-20'
29     invoice_quantity: order
30     name: TEST/TENDER/0002
31     order_line:
32       - name: Laptop ACER1
33         price_unit: 1000.0
34         product_uom: product.product_uom_unit
35         product_uom_qty: 5.0
36         state: draft
37         'delay': 7.0
38         'product_id': product_product_laptopacer1
39         'type': make_to_order
40     order_policy: manual
41     partner_id: base.res_partner_agrolait
42     partner_invoice_id: base.res_partner_address_8
43     partner_order_id: base.res_partner_address_8
44     partner_shipping_id: base.res_partner_address_8
45     picking_policy: direct
46     pricelist_id: product.list0
47     shop_id: sale.shop    
48
49   I confirm  sale order.
50
51   !workflow {model: sale.order, action: order_confirm, ref: sale_order_testtender1}
52
53   I launch he scheduler to compute all procurements, and planify all requisitions orders.
54 -  
55   !python {model: mrp.procurement.compute.all}: |
56     proc_obj = self.pool.get('mrp.procurement')
57     proc_obj._procure_confirm(cr,uid)
58 -
59   I should find a purchase requisition with the origin 'TEST/TENDER/0002', that includes a request for
60   5 Laptop ACER, and a purchase order on the default supplier for this product.
61 -    
62  !python {model: purchase.requisition}: |
63     requisition_ids =self.search(cr, uid, [('origin','=','TEST/TENDER/0002')])
64     ids=len(requisition_ids)
65     assert len(requisition_ids), "Purchase requisition  hasn't Created"
66 -
67   On the purchase tender, I create a new purchase order for the supplier 'DistriPC' by clicking on
68   the button 'New Request for Quotation'. This opens a window to ask me the supplier and I set DistriPC .
69
70   I Create  purchase.requisition.partner .
71
72   !record {model: purchase.requisition.partner, id: purchase_requisition_partner_0}:
73     partner_address_id: base.res_partner_address_7
74     partner_id: base.res_partner_4
75
76   I create a new purchase order for the supplier 'DistriPC'.
77
78   !python {model: purchase.requisition.partner}: |
79     req_obj = self.pool.get('purchase.requisition')
80     ids =req_obj.search(cr, uid, [('origin','=','TEST/TENDER/0002')])
81     self.create_order(cr, uid, [ref("purchase_requisition_partner_0")], {"lang":
82       'en_US', "active_model": "purchase.requisition", "tz": False, "record_id":
83       1, "active_ids": ids, "active_id": ids[0], })
84 -
85   I set the purchase tender as 'Exclusive'      
86
87   !python {model: purchase.requisition}: |
88     ids =self.search(cr, uid, [('origin','=','TEST/TENDER/0002')])
89     self.write(cr,uid,ids[0],{'exclusive': 'exclusive' })
90 -
91   I confirm and validate the Request for Quotation of ASUStek.      
92 -
93  !python {model: purchase.order}: |
94     partner_id=self.pool.get('res.partner').search(cr,uid,[('name','=','ASUStek')])[0]
95     req_obj = self.pool.get('purchase.requisition')
96     ids =req_obj.search(cr, uid, [('origin','=','TEST/TENDER/0002')])    
97     purchase_id= self.search(cr, uid, [('partner_id','=',partner_id),('requisition_id','in',ids)])[0]
98     import netsvc
99     wf_service = netsvc.LocalService("workflow")  
100     if purchase_id:
101       wf_service.trg_validate(uid, 'purchase.order',purchase_id,'purchase_confirm', cr)
102       wf_service.trg_validate(uid, 'purchase.order',purchase_id,'purchase_approve', cr)  
103 -
104   I check that Request for Quotation of DistriPC is cancelled.
105 -        
106   !python {model: purchase.order}: |
107    partner_id=self.pool.get('res.partner').search(cr,uid,[('name','=','Distrib PC')])[0]
108    req_obj = self.pool.get('purchase.requisition')
109    ids =req_obj.search(cr, uid, [('origin','=','TEST/TENDER/0002')])     
110    purchase_id= self.search(cr, uid, [('partner_id','=',partner_id),('requisition_id','in',ids)])[0]
111    state=self.browse(cr,uid,purchase_id).state
112    assert (state=='cancel')