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.
5 I start by creating a new product 'Laptop ACER', which is purchased at Asustek, in MTO,
6 with the generation of purchase requisitions.
8 !record {model: product.product, id: product_product_laptopacer1}:
9 categ_id: product.product_category_3
14 procure_method: make_to_order
15 purchase_requisition: 1
18 name: base.res_partner_asus
22 uom_id: product.product_uom_unit
23 uom_po_id: product.product_uom_unit
25 Then I sell 5 Laptop ACER to the customer Agrolait, sale order TEST/TENDER/0002
27 !record {model: sale.order, id: sale_order_testtender1}:
28 date_order: '2010-04-20'
29 invoice_quantity: order
30 name: TEST/TENDER/0002
34 product_uom: product.product_uom_unit
38 'product_id': product_product_laptopacer1
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
51 !workflow {model: sale.order, action: order_confirm, ref: sale_order_testtender1}
53 I launch he scheduler to compute all procurements, and planify all requisitions orders.
55 !python {model: mrp.procurement.compute.all}: |
56 proc_obj = self.pool.get('mrp.procurement')
57 proc_obj._procure_confirm(cr,uid)
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.
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"
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 .
70 I Create purchase.requisition.partner .
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
76 I create a new purchase order for the supplier 'DistriPC'.
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], })
85 I set the purchase tender as 'Exclusive'
87 !python {model: purchase.requisition}: |
88 ids =self.search(cr, uid, [('origin','=','TEST/TENDER/0002')])
89 self.write(cr,uid,ids[0],{'exclusive': 'exclusive' })
91 I confirm and validate the Request for Quotation of ASUStek.
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]
99 wf_service = netsvc.LocalService("workflow")
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)
104 I check that Request for Quotation of DistriPC is cancelled.
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')