3 In order to test the purchase requisition module, I will do a sale order -> purchase_requisition ->
4 purchase flow and I will buy the required products at two different suppliers.
6 I start by creating a new product 'Laptop ACER', which is purchased at Asustek, in MTO,
7 with the generation of purchase requisitions.
9 !record {model: product.product, id: product_product_laptopacer0}:
10 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
30 Then I sell 5 Laptop ACER to the customer Agrolait, sale order TEST/TENDER/0001.
32 !record {model: sale.order, id: sale_order_testtender0}:
33 date_order: '2010-05-10'
34 invoice_quantity: order
35 name: TEST/TENDER/0001
39 product_uom: product.product_uom_unit
43 product_id: product_product_laptopacer0
48 partner_id: base.res_partner_agrolait
49 partner_invoice_id: base.res_partner_address_8
50 partner_order_id: base.res_partner_address_8
51 partner_shipping_id: base.res_partner_address_8
52 picking_policy: direct
53 pricelist_id: product.list0
56 I confirm the sale order.
58 !workflow {model: sale.order, action: order_confirm, ref: sale_order_testtender0}
60 I launch he scheduler to compute all procurements, and specify all requisitions orders.
62 !python {model: mrp.procurement.compute.all}: |
63 proc_obj = self.pool.get('mrp.procurement')
64 proc_obj._procure_confirm(cr,uid)
66 On the purchase tender, I create a new purchase order for the supplier 'DistriPC' by clicking on
67 the button 'New RfQ'. This opens a window to ask me the supplier and I set DistriPC .
69 !record {model: purchase.requisition.partner, id: purchase_requisition_partner_0}:
70 partner_address_id: base.res_partner_address_7
71 partner_id: base.res_partner_4
73 I create a new purchase order.
75 !python {model: purchase.requisition.partner}: |
76 req_obj = self.pool.get('purchase.requisition')
77 ids =req_obj.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
78 self.create_order(cr, uid, [ref("purchase_requisition_partner_0")], {"lang":
79 'en_US', "active_model": "purchase.requisition", "tz": False, "record_id":
80 1, "active_ids": ids, "active_id": ids[0], })
83 I check that I have two purchase orders on the purchase tender.
85 !python {model: purchase.order}: |
86 order_ids =self.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
88 assert (ids==2), "Purchase order hasn't Created"
90 I set the purchase requisition as 'Not Exclusive'.
92 !python {model: purchase.requisition}: |
93 ids =self.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
94 self.write(cr,uid,ids[0],{'exclusive': 'multiple' })
96 I change the quantities so that the purchase order for DistriPC includes 3 pieces and the
97 purchase order for Asustek includes 2 pieces.
99 !python {model: purchase.order}: |
100 line_obj=self.pool.get('purchase.order.line')
101 partner_obj=self.pool.get('res.partner')
102 requistion_obj=self.pool.get('purchase.requisition')
103 requistion_ids =requistion_obj.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
104 partner_id1=partner_obj.search(cr,uid,[('name','=','ASUStek')])[0]
105 partner_id2=partner_obj.search(cr,uid,[('name','=','Distrib PC')])[0]
106 purchase_id1= self.search(cr, uid, [('partner_id','=',partner_id1),('requisition_id','in',requistion_ids)])
107 purchase_id2= self.search(cr, uid, [('partner_id','=',partner_id2),('requisition_id','in',requistion_ids)])
108 order_line1=self.browse(cr, uid, purchase_id1, context)[0].order_line[0].id
109 order_line2=self.browse(cr, uid, purchase_id2, context)[0].order_line[0].id
110 line_obj.write(cr, uid, order_line1, {'product_qty':2})
111 line_obj.write(cr, uid, order_line2, {'product_qty':3})
113 I confirm and validate both purchase orders.
115 !python {model: purchase.order}: |
116 order_ids= self.search(cr, uid, [])
118 wf_service = netsvc.LocalService("workflow")
120 wf_service.trg_validate(uid, 'purchase.order',id,'purchase_confirm', cr)
121 wf_service.trg_validate(uid, 'purchase.order',id,'purchase_approve', cr)
123 I check that the delivery order of the customer is in state 'Waiting Goods'.
125 !python {model: stock.picking }: |
126 picking_id = self.search(cr, uid, [('origin','=','TEST/TENDER/0001'),('type','=','delivery')])
128 pick=self.browse(cr,uid,picking_id[0])
129 assert (pick.state) =='confirmed'," Order is not confirm"
130 assert(pick.move_lines[0].state=='wating'),'Order is not wating"'
132 I receive the order of the supplier Asustek from the Incoming Products menu.
134 !python {model: stock.picking }: |
136 partner_obj=self.pool.get('res.partner')
137 order_obj=self.pool.get('purchase.order')
138 partner_id=partner_obj.search(cr,uid,[('name','=','ASUStek')])[0]
139 picking_id = self.search(cr, uid, [('address_id.partner_id','=',partner_id),('type','=','in')])
141 pick=self.browse(cr,uid,picking_id[0])
142 move =pick.move_lines[0]
146 'delivery_date' : time.strftime('%Y-%m-%d'),
148 partial_datas['move%s'%(move.id)]= {
149 'product_id': move.product_id,
150 'product_qty': move.product_qty,
151 'product_uom': move.product_uom.id,
153 self.do_partial(cr, uid, picking_id,partial_datas)
155 I receive the order of the supplier DistriPC from the Incoming Shipments menu.
157 !python {model: stock.picking }: |
159 partner_id=self.pool.get('res.partner').search(cr,uid,[('name','=','Distrib PC')])[0]
160 picking_id = self.search(cr, uid, [('address_id.partner_id','=',partner_id),('type','=','in')])
162 pick=self.browse(cr,uid,picking_id[0])
163 move =pick.move_lines[0]
165 'partner_id':pick.address_id.partner_id.id,
166 'address_id': pick.address_id.id,
167 'delivery_date' : time.strftime('%Y-%m-%d'),
169 partial_datas['move%s'%(move.id)]= {
170 'product_id': move.product_id,
171 'product_qty': move.product_qty,
172 'product_uom': move.product_uom.id,
174 self.do_partial(cr, uid, picking_id,partial_datas)
176 I check that the delivery order of the customer is in the state Available.
178 !python {model: stock.picking }: |
179 picking_id = self.search(cr, uid, [('origin','=','TEST/TENDER/0001'),('type','=','out')])
181 pick=self.browse(cr,uid,picking_id[0])
182 assert (pick.state) =='available'," Order is not available"