3
Creating a res.partner record
5
!record {model: res.partner, id: res_partner_0}:
16
Creating a res.partner.address record
18
!record {model: res.partner.address, id: res_partner_address_0}:
19
partner_id: res_partner_0
23
Creating a res.partner record
25
!record {model: res.partner, id: res_partner_1}:
33
Creating a res.partner.address record
35
!record {model: res.partner.address, id: res_partner_address_1}:
36
partner_id: res_partner_1
40
I create product template .
42
!record {model: product.template, id: product_template_p0}:
43
categ_id: product.cat0
46
name: Product0 - tender test
47
procure_method: make_to_order
51
uom_id: product.product_uom_unit
52
uom_po_id: product.product_uom_unit
55
Creating a product.product record
57
!record {model: product.product, id: product_product_p0}:
60
valuation: manual_periodic
65
product_tmpl_id: product_template_p0
66
international_status: itc
70
Creating a product.supplierinfo record
72
!record {model: product.supplierinfo, id: product_supplierinfo_0}:
76
product_id: product_template_p0
80
Creating a product.supplierinfo record
82
!record {model: product.supplierinfo, id: product_supplierinfo_1}:
86
product_id: product_template_p0
91
!record {model: res.partner, id: supplier1}:
97
I create the corresponding addresses
99
!record {model: res.partner.address, id: supplier_address_1}:
101
partner_id: supplier1
105
In order to test the procurement list module, I start by creating a new product category
107
!record {model: product.category, id: product_cat1}:
110
Creating a sale.order record
112
!record {model: sale.order, id: sale_order_tender_so0}:
116
company_id: base.main_company
117
date_order: '2011-04-13'
118
invoice_quantity: order
120
partner_id: res_partner_0
121
partner_invoice_id: res_partner_address_0
122
partner_order_id: res_partner_address_0
123
partner_shipping_id: res_partner_address_0
124
picking_policy: direct
125
pricelist_id: product.list0
132
Creating a sale.order.line record
134
!record {model: sale.order.line, id: sale_order_line_tender_p0}:
135
company_id: base.main_company
137
order_id: sale_order_tender_so0
138
order_partner_id: res_partner_0
140
product_id: product_product_p0
141
product_uom: product.product_uom_unit
143
salesman_id: base.user_admin
150
I check the sourcing line
153
!python {model: sale.order.line}: |
154
sol = self.browse(cr, uid, ref("sale_order_line_tender_p0"))
158
for sourcing in sol.sourcing_line_ids:
160
assert sourcing.sale_order_id.id == ref("sale_order_tender_so0"), 'sourcing line, sale order id is wrong (%i, %i)'%(sourcing.sale_order_id, ref("sale_order_tender_so0"))
161
assert int(sourcing.sale_order_line_id) == ref("sale_order_line_tender_p0"), 'sourcing line, sale order line id is wrong (%i, %i)'%(sourcing.sale_order_line_id, ref("sale_order_line_tender_p0"))
162
assert sourcing.type == 'make_to_stock', 'sourcing type wrong'
163
assert sourcing.state == 'draft', 'sourcing state wrong (draft, %s)'%sourcing.state
164
assert sourcing.state == sourcing.sale_order_line_state, 'states wrong'
165
assert not sourcing.supplier.id, 'make_to_stock: sourcing has a supplier !'
167
sourcing.write({'type':'make_to_order', 'supplier':ref("res_partner_1"), 'po_cft':'cft',})
169
assert not sol.supplier, 'sol supplier is wrong after update of sourcing line (%s, %s)'%(sol.supplier, False)
170
assert sol.type == 'make_to_order', 'sol type is wrong after update of sourcing line (%s, %s)'%(sol.type, 'make_to_order')
171
assert sol.po_cft == 'cft', 'po_cft is wrong after update of sourcing line (%s, %s)'%(sol.po_cft, 'cft')
173
assert count == 1, 'number of sourcing line wrong (%i)'%(count)
176
I trigger the workflow
179
!python {model: sale.order.line}: |
181
wf_service = netsvc.LocalService("workflow")
182
wf_service.trg_validate(uid, 'sale.order', ref("sale_order_tender_so0"), 'order_confirm', cr)
187
I check the new procurement order
190
!python {model: procurement.order}: |
191
ids = self.search(cr, uid, [('name', '=', 'Product0 - tender test'),], context=context)
192
assert len(ids) == 1, 'wrong number of procurement. %s-%s'%(len(ids), 1)
200
!function {model: procurement.order, name: run_scheduler}:
201
- model: procurement.order
206
I check a tender has been created with one corresponding line
210
!python {model: tender}: |
211
ids = self.search(cr, uid, [('sale_order_id', '=', ref("sale_order_tender_so0")),], context=context)
213
assert len(ids) == 1, 'number of tender is wrong. %s-%s'%(len(ids), 1)
215
# create suppliers. table: tender_supplier_rel
216
cr.execute('insert into tender_supplier_rel (tender_id,supplier_id) values (%s,%s)', (ids[0], ref("res_partner_0")))
219
wf_service = netsvc.LocalService("workflow")
220
wf_service.trg_validate(uid, 'tender', ids[0], 'button_generate', cr)
224
check the number of po
228
!python {model: purchase.order}: |
229
# as an order point has been generated with the same partner, we must specify the origin also as beeing not 'SCHEDULER'
230
ids = self.search(cr, uid, [('partner_id', '=', ref("res_partner_0")), ('origin', '!=', 'SCHEDULER'),], context=context)
231
assert len(ids) == 1, 'number of rfq is wrong. %s-%s'%(len(ids), 1)
233
# update the price_unit of purchase order line
235
for po in self.browse(cr, uid, ids):
236
# update valid till date
237
po.write({'valid_till': '2011-10-31',})
238
for pol in po.order_line:
239
pol.write({'price_unit':10024})
240
tender_id = po.tender_id
241
# trigger the workflow
243
wf_service = netsvc.LocalService("workflow")
244
wf_service.trg_validate(uid, 'purchase.order', po.id, 'rfq_sent', cr)
245
wf_service.trg_validate(uid, 'purchase.order', po.id, 'rfq_updated', cr)
247
# simulate the compare rfq wizard
248
wiz_obj = self.pool.get('wizard.compare.rfq')
249
action_dic = wiz_obj.start_compare_rfq(cr, uid, ids, context=dict(context, active_ids=ids, tender_id=tender_id))
250
wiz_id = action_dic['res_id']
251
wiz = wiz_obj.browse(cr, uid, wiz_id)
252
wiz_line = wiz.line_ids[0]
253
# choose the supplier
254
choose_dic = wiz_line.choose_supplier()
255
choose_id = choose_dic['res_id']
257
# choose supplier wizard
258
choose_obj = self.pool.get('wizard.choose.supplier')
259
choose_line = choose_obj.browse(cr, uid, choose_id).line_ids[0]
260
choose_line.choose_supplier()
262
# back to first wizard
267
verify price_unit in tender line and validate the tender
271
!python {model: tender}: |
272
ids = self.search(cr, uid, [('sale_order_id', '=', ref("sale_order_tender_so0")),], context=context)
273
assert ids, 'ids is empty'
274
tender = self.browse(cr, uid, ids[0])
275
assert tender.tender_line_ids[0].price_unit == 10024, 'price_unit has not been updated. %s-10024'%tender.tender_line_ids[0].price_unit
276
# update context in order analytic distribution not to be tested
277
context.update({'update_mode': 'init'})
278
po_id = self.create_po(cr, uid, tender.id, context=context)
281
wf_service = netsvc.LocalService("workflow")
282
wf_service.trg_validate(uid, 'tender', tender.id, 'button_done', cr)
284
# all rfqs must be rfq_done
285
for rfq in tender.rfq_ids:
286
assert rfq.state == 'done', 'the state of the rfq is not done : done - %s'%rfq.state
288
# the final po must have state = 'confirmed'
289
po_obj = self.pool.get('purchase.order')
290
so_obj = self.pool.get('sale.order')
291
so = so_obj.browse(cr, uid, ref("sale_order_tender_so0"))
292
so_ids = po_obj.search(cr, uid, [])
293
ids = po_obj.search(cr, uid, [('origin', '=', so.name + ';' + tender.name),('id', '=', po_id)])
294
assert ids, 'The origin of the generated purchase order is not correct'
295
po = po_obj.browse(cr, uid, ids[0])
296
assert po.state == 'draft', 'the state of purchase order is wrong. %s-draft'%po.state # state depends on the installation or not of double validation module for purchase order