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
23 uom_id: product.product_uom_unit
24 uom_po_id: product.product_uom_unit
31 Then I sell 5 Laptop ACER to the customer Agrolait, sale order TEST/TENDER/0001.
33 !record {model: sale.order, id: sale_order_testtender0}:
34 date_order: !eval time.strftime('%Y-%m-%d')
35 invoice_quantity: order
36 name: TEST/TENDER/0001
40 product_uom: product.product_uom_unit
44 product_id: product_product_laptopacer0
49 partner_id: base.res_partner_agrolait
50 partner_invoice_id: base.res_partner_address_8
51 partner_order_id: base.res_partner_address_8
52 partner_shipping_id: base.res_partner_address_8
53 picking_policy: direct
54 pricelist_id: product.list0
57 I confirm the sale order.
59 !workflow {model: sale.order, action: order_confirm, ref: sale_order_testtender0}
61 I launch the scheduler to compute all procurements, and specify all requisitions orders.
63 !python {model: procurement.order.compute.all}: |
64 proc_obj = self.pool.get('procurement.order')
65 proc_obj._procure_confirm(cr,uid)
67 On the purchase requisition, I create a new purchase order for the supplier 'DistriPC' by clicking on
68 the button 'New RfQ'. This opens a window to ask me the supplier and I set DistriPC .
70 !record {model: purchase.requisition.partner, id: purchase_requisition_partner_0}:
71 partner_address_id: base.res_partner_address_7
72 partner_id: base.res_partner_4
74 I create a new purchase order.
76 !python {model: purchase.requisition.partner}: |
77 req_obj = self.pool.get('purchase.requisition')
78 ids =req_obj.search(cr, uid, [('origin','=','Laptop ACER')])
79 self.create_order(cr, uid, [ref("purchase_requisition_partner_0")], {"lang":
80 'en_US', "active_model": "purchase.requisition", "tz": False, "record_id":
81 1, "active_ids": ids, "active_id": ids[0], })
84 I check that I have two purchase orders on the purchase requisition.
86 !python {model: purchase.order}: |
87 from tools.translate import _
88 order_ids =self.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
90 assert(ids == 2), _('Purchase Order not Created')
93 I set the purchase requisition as 'Not Exclusive'.
95 !python {model: purchase.requisition}: |
96 ids =self.search(cr, uid, [('origin','=','Laptop ACER')])
97 self.write(cr,uid,ids[0],{'exclusive': 'multiple' })
99 I change the quantities so that the purchase order for DistriPC includes 3 pieces and the
100 purchase order for Asustek includes 2 pieces.
102 !python {model: purchase.order}: |
103 line_obj=self.pool.get('purchase.order.line')
104 partner_obj=self.pool.get('res.partner')
105 requistion_obj=self.pool.get('purchase.requisition')
106 requistion_ids =requistion_obj.search(cr, uid, [('origin','=','Laptop ACER')])
107 partner_id1=partner_obj.search(cr,uid,[('name','=','ASUStek')])[0]
108 partner_id2=partner_obj.search(cr,uid,[('name','=','Distrib PC')])[0]
109 purchase_id1= self.search(cr, uid, [('partner_id','=',partner_id1),('requisition_id','in',requistion_ids)])
110 purchase_id2= self.search(cr, uid, [('partner_id','=',partner_id2),('requisition_id','in',requistion_ids)])
111 order_line1=self.browse(cr, uid, purchase_id1, context)[0].order_line[0].id
112 order_line2=self.browse(cr, uid, purchase_id2, context)[0].order_line[0].id
113 line_obj.write(cr, uid, order_line1, {'product_qty':2})
114 line_obj.write(cr, uid, order_line2, {'product_qty':3})
116 I confirm and validate both purchase orders.
118 !python {model: purchase.order}: |
119 order_ids= self.search(cr, uid, [])
121 wf_service = netsvc.LocalService("workflow")
123 wf_service.trg_validate(uid, 'purchase.order',id,'purchase_confirm', cr)
124 wf_service.trg_validate(uid, 'purchase.order',id,'purchase_approve', cr)
126 I check that the delivery order of the customer is in state 'Waiting Goods'.
128 !python {model: stock.picking }: |
129 from tools.translate import _
130 picking_id = self.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
132 pick=self.browse(cr,uid,picking_id[0])
133 assert (pick.state =='confirmed'),_('Picking is not in confirm state.')
134 assert (pick.move_lines[0].state == 'waiting'), _('Stock Move is not Waiting state.')
137 I receive the order of the supplier Asustek from the Incoming Products menu.
139 !python {model: stock.picking }: |
141 partner_obj=self.pool.get('res.partner')
142 order_obj=self.pool.get('purchase.order')
143 partner_id=partner_obj.search(cr,uid,[('name','=','ASUStek')])[0]
144 picking_id = self.search(cr, uid, [('address_id.partner_id','=',partner_id),('type','=','in')])
146 pick=self.browse(cr,uid,picking_id[0])
147 move =pick.move_lines[0]
149 'partner_id': pick.address_id.partner_id.id,
150 'address_id': pick.address_id.id,
151 'delivery_date' : time.strftime('%Y-%m-%d'),
153 partial_datas['move%s'%(move.id)]= {
154 'product_id': move.product_id.id,
155 'product_qty': move.product_qty,
156 'product_uom': move.product_uom.id,
158 self.do_partial(cr, uid, picking_id,partial_datas)
160 I receive the order of the supplier DistriPC from the Incoming Shipments menu.
162 !python {model: stock.picking }: |
164 partner_id=self.pool.get('res.partner').search(cr,uid,[('name','=','Distrib PC')])[0]
165 picking_id = self.search(cr, uid, [('address_id.partner_id','=',partner_id),('type','=','in')])
167 pick=self.browse(cr,uid,picking_id[0])
168 move =pick.move_lines[0]
170 'partner_id':pick.address_id.partner_id.id,
171 'address_id': pick.address_id.id,
172 'delivery_date' : time.strftime('%Y-%m-%d'),
174 partial_datas['move%s'%(move.id)]= {
175 'product_id': move.product_id.id,
176 'product_qty': move.product_qty,
177 'product_uom': move.product_uom.id,
179 self.do_partial(cr, uid, picking_id,partial_datas)
181 I check that the delivery order of the customer is in the state Available.
183 !python {model: stock.picking }: |
184 from tools.translate import _
185 picking_id = self.search(cr, uid, [('origin','=','TEST/TENDER/0001'),('type','=','out')])
187 pick=self.browse(cr,uid,picking_id[0])
188 assert(pick.state == 'assigned'), _('Picking is not in available state')