2
In order to test the new purchase order line screen, we first create new partners.
3
We then create new products with different internal and supplier configuration (code and name).
5
Finally we create purchase orders with purchase order lines for these different products.
8
Creating a product.category record
10
!record {model: product.category, id: product_category_testproducts0}:
15
I create the first partner,
21
Creating a res.partner record
23
!record {model: res.partner, id: res_partner_africom0}:
29
I create the second partner,
35
Creating a res.partner record
37
!record {model: res.partner, id: res_partner_alaindeloin0}:
43
I create the third partner,
49
Creating a res.partner record
51
!record {model: res.partner, id: res_partner_berthe0}:
58
I create the corresponding addresses
61
Creating a res.partner.address record
63
!record {model: res.partner.address, id: res_partner_address_0}:
65
partner_id: res_partner_africom0
72
Creating a res.partner.address record
74
!record {model: res.partner.address, id: res_partner_address_2}:
75
partner_id: res_partner_alaindeloin0
80
Creating a res.partner.address record
82
!record {model: res.partner.address, id: res_partner_address_3}:
83
partner_id: res_partner_berthe0
87
I create the first product, with no specified suppliers,
88
Name Boite à chaussures
89
Reference CHAUSS INT 1234
92
Creating a product.product record
94
!record {model: product.product, id: product_product_boitechaussures0}:
95
categ_id: product_category_testproducts0
97
default_code: CHAUSS-INT-1234
99
name: Boite \xc3\xa0 chaussures
100
name_template: Boite \xc3\xa0 chaussures
101
procure_method: make_to_stock
107
uom_id: product.product_uom_unit
108
uom_po_id: product.product_uom_unit
109
valuation: manual_periodic
115
I create the second product, with one specified supplier,
117
Reference CAM-INT-1234
119
* Supplier product Name Fromage qui pue Africom
120
* Supplier product Code PUE AFRI 1234
123
Creating a product.product record
125
!record {model: product.product, id: product_product_camembert0}:
126
categ_id: product_category_testproducts0
127
cost_method: standard
128
default_code: CAM-INT-1234
131
name_template: Camembert
132
procure_method: make_to_stock
134
seller_id: res_partner_africom0
138
name: res_partner_africom0
139
product_code: PUE-AFRI-1234
140
product_name: Fromage qui pue Africom
145
uom_id: product.product_uom_unit
146
uom_po_id: product.product_uom_unit
147
valuation: manual_periodic
153
I create the third product, with two specified supplier, the first one with supplier info, the second one without,
155
Reference PNEU INT 1234
157
* Supplier product Name Pneu AlainDeLoin
158
* Supplier product Code PNEU ALAIN 1234
162
Creating a product.product record
164
!record {model: product.product, id: product_product_pneu0}:
165
categ_id: product_category_testproducts0
166
cost_method: standard
167
default_code: PNEU-INT-1234
171
procure_method: make_to_stock
173
seller_id: res_partner_alaindeloin0
177
name: res_partner_alaindeloin0
178
product_code: PNEU-ALAIN-1234
179
product_name: Pneu AlainDeLoin
182
name: res_partner_berthe0
187
uom_id: product.product_uom_unit
188
uom_po_id: product.product_uom_unit
189
valuation: manual_periodic
196
I create the first purchase order
198
The selected product has AFRICOM as specified supplier
201
Creating a purchase.order record
203
!record {model: purchase.order, id: purchase_order_po1}:
207
company_id: base.main_company
208
date_order: '2011-03-15'
209
invoice_method: order
210
location_id: stock.stock_location_stock
211
minimum_planned_date: '2011-03-15'
213
partner_address_id: res_partner_address_0
214
partner_id: res_partner_africom0
215
pricelist_id: purchase.list0
218
I create the order line
220
Creating a purchase.order.line record
222
!record {model: purchase.order.line, id: purchase_order_line_boitechaussures0}:
223
company_id: base.main_company
224
date_planned: '2011-03-15'
225
internal_code: CHAUSS-INT-1234
226
internal_name: Boite \xc3\xa0 chaussures
227
name: Boite \xc3\xa0 chaussures
228
order_id: purchase_order_po1
229
partner_id: res_partner_africom0
231
product_id: product_product_boitechaussures0
233
product_uom: product.product_uom_unit
237
I check the onchange function, it should correspond
238
to data from selected product supplier
240
gather corresponding purchase order line
241
retrieve the values from onChange function
242
compare the data with the one from pol
251
!python {model: purchase.order.line}: |
252
pol = self.browse(cr, uid, ref("purchase_order_line_boitechaussures0"))
254
result = pol.product_id_change(pol.order_id.pricelist_id.id, pol.product_id.id,
255
pol.product_qty, pol.product_uom.id, pol.order_id.partner_id.id,
256
pol.order_id.date_order, pol.order_id.fiscal_position.id,
257
pol.date_planned, pol.name, pol.price_unit, pol.notes)
259
innerDic = result['value']
261
assert innerDic['name'] == pol.name
262
assert (innerDic['internal_code'] or '') == (pol.internal_code or ''), "internal_code %s vs %s" % (innerDic['internal_code'], pol.internal_code)
263
assert (innerDic['internal_name'] or '') == (pol.internal_name or ''), "internal_name %s vs %s" % (innerDic['internal_name'], pol.internal_name)
264
assert (innerDic['supplier_code'] or '') == (pol.supplier_code or ''), "supplier_code %s vs %s" % (innerDic['supplier_code'], pol.supplier_code)
265
assert (innerDic['supplier_name'] or '') == (pol.supplier_name or ''), "supplier_name %s vs %s" % (innerDic['supplier_name'], pol.supplier_name)
269
create a PO with supplier alaindeloin and product pneu
270
pneu has alaindeloin as one of its supplier. Supplier
271
information is specified
274
Creating a purchase.order record
276
!record {model: purchase.order, id: purchase_order_po0}:
280
company_id: base.main_company
281
date_order: '2011-03-15'
282
invoice_method: order
283
location_id: stock.stock_location_stock
284
minimum_planned_date: '2011-03-16'
286
partner_address_id: res_partner_address_2
287
partner_id: res_partner_alaindeloin0
288
pricelist_id: purchase.list0
292
I create the order line
294
Creating a purchase.order.line record
296
!record {model: purchase.order.line, id: purchase_order_line_pneu2}:
297
company_id: base.main_company
298
date_planned: '2011-03-16'
299
internal_code: PNEU-INT-1234
302
order_id: purchase_order_po0
303
partner_id: res_partner_alaindeloin0
305
product_id: product_product_pneu0
307
product_uom: product.product_uom_unit
309
supplier_code: PNEU-ALAIN-1234
310
supplier_name: Pneu AlainDeLoin
313
I check the onchange function, it should correspond
314
to data from selected product supplier
316
gather corresponding purchase order line
317
retrieve the values from onChange function
318
compare the data with the one from pol
327
!python {model: purchase.order.line}: |
328
pol = self.browse(cr, uid, ref("purchase_order_line_pneu2"))
330
result = pol.product_id_change(pol.order_id.pricelist_id.id, pol.product_id.id,
331
pol.product_qty, pol.product_uom.id, pol.order_id.partner_id.id,
332
pol.order_id.date_order, pol.order_id.fiscal_position.id,
333
pol.date_planned, pol.name, pol.price_unit, pol.notes)
335
innerDic = result['value']
337
assert innerDic['name'] == pol.name
338
assert (innerDic['internal_code'] or '') == (pol.internal_code or ''), "internal_code %s vs %s" % (innerDic['internal_code'], pol.internal_code)
339
assert (innerDic['internal_name'] or '') == (pol.internal_name or ''), "internal_name %s vs %s" % (innerDic['internal_name'], pol.internal_name)
340
assert (innerDic['supplier_code'] or '') == (pol.supplier_code or ''), "supplier_code %s vs %s" % (innerDic['supplier_code'], pol.supplier_code)
341
assert (innerDic['supplier_name'] or '') == (pol.supplier_name or ''), "supplier_name %s vs %s" % (innerDic['supplier_name'], pol.supplier_name)
345
create a PO with berthe as its supplier and pneu. berthe
346
is one of the specified supplier for pneu, but with no
347
supplier information (code and name)
349
Creating a purchase.order record
351
!record {model: purchase.order, id: purchase_order_po2}:
355
company_id: base.main_company
356
date_order: '2011-03-15'
357
invoice_method: order
358
location_id: stock.stock_location_stock
359
minimum_planned_date: '2011-03-16'
361
partner_address_id: res_partner_address_3
362
partner_id: res_partner_berthe0
363
pricelist_id: purchase.list0
367
I create the order line
369
Creating a purchase.order.line record
371
!record {model: purchase.order.line, id: purchase_order_line_pneu1}:
372
company_id: base.main_company
373
date_planned: '2011-03-16'
374
internal_code: PNEU-INT-1234
377
order_id: purchase_order_po2
378
partner_id: res_partner_berthe0
380
product_id: product_product_pneu0
382
product_uom: product.product_uom_unit
386
I check the onchange function, it should correspond
387
to data from selected product supplier
389
gather corresponding purchase order line
390
retrieve the values from onChange function
391
compare the data with the one from pol
400
!python {model: purchase.order.line}: |
401
pol = self.browse(cr, uid, ref("purchase_order_line_pneu1"))
403
result = pol.product_id_change(pol.order_id.pricelist_id.id, pol.product_id.id,
404
pol.product_qty, pol.product_uom.id, pol.order_id.partner_id.id,
405
pol.order_id.date_order, pol.order_id.fiscal_position.id,
406
pol.date_planned, pol.name, pol.price_unit, pol.notes)
408
innerDic = result['value']
410
assert innerDic['name'] == pol.name
411
assert (innerDic['internal_code'] or '') == (pol.internal_code or ''), "internal_code %s vs %s" % (innerDic['internal_code'], pol.internal_code)
412
assert (innerDic['internal_name'] or '') == (pol.internal_name or ''), "internal_name %s vs %s" % (innerDic['internal_name'], pol.internal_name)
413
assert (innerDic['supplier_code'] or '') == (pol.supplier_code or ''), "supplier_code %s vs %s" % (innerDic['supplier_code'], pol.supplier_code)
414
assert (innerDic['supplier_name'] or '') == (pol.supplier_name or ''), "supplier_name %s vs %s" % (innerDic['supplier_name'], pol.supplier_name)
418
create a PO with supplier AFRICOM. and product Pneu,
419
Pneu has two suppliers specified but none of them is AFRICOM
422
Creating a purchase.order record
424
!record {model: purchase.order, id: purchase_order_po3}:
428
company_id: base.main_company
429
date_order: '2011-03-15'
430
invoice_method: order
431
location_id: stock.stock_location_stock
432
minimum_planned_date: '2011-03-16'
434
partner_address_id: res_partner_address_0
435
partner_id: res_partner_africom0
436
pricelist_id: purchase.list0
439
I create the order line
441
Creating a purchase.order.line record
443
!record {model: purchase.order.line, id: purchase_order_line_pneu0}:
444
company_id: base.main_company
445
date_planned: '2011-03-16'
446
internal_code: PNEU-INT-1234
449
order_id: purchase_order_po3
450
partner_id: res_partner_africom0
452
product_id: product_product_pneu0
454
product_uom: product.product_uom_unit
458
I check the onchange function, it should correspond
459
to data from selected product supplier
461
gather corresponding purchase order line
462
retrieve the values from onChange function
463
compare the data with the one from pol
472
!python {model: purchase.order.line}: |
473
pol = self.browse(cr, uid, ref("purchase_order_line_pneu0"))
475
result = pol.product_id_change(pol.order_id.pricelist_id.id, pol.product_id.id,
476
pol.product_qty, pol.product_uom.id, pol.order_id.partner_id.id,
477
pol.order_id.date_order, pol.order_id.fiscal_position.id,
478
pol.date_planned, pol.name, pol.price_unit, pol.notes)
480
innerDic = result['value']
482
assert innerDic['name'] == pol.name
483
assert (innerDic['internal_code'] or '') == (pol.internal_code or ''), "internal_code %s vs %s" % (innerDic['internal_code'], pol.internal_code)
484
assert (innerDic['internal_name'] or '') == (pol.internal_name or ''), "internal_name %s vs %s" % (innerDic['internal_name'], pol.internal_name)
485
assert (innerDic['supplier_code'] or '') == (pol.supplier_code or ''), "supplier_code %s vs %s" % (innerDic['supplier_code'], pol.supplier_code)
486
assert (innerDic['supplier_name'] or '') == (pol.supplier_name or ''), "supplier_name %s vs %s" % (innerDic['supplier_name'], pol.supplier_name)