2
Creating a sale.order record A
4
!record {model: sale.order, id: outgoing_so_A}:
9
company_id: base.main_company
10
date_order: '2011-04-13'
11
invoice_quantity: order
13
partner_id: outgoing_partner_A
14
partner_invoice_id: outgoing_address_A
15
partner_order_id: outgoing_address_A
16
partner_shipping_id: outgoing_address_A
17
picking_policy: direct
18
pricelist_id: product.list0
23
Creating a sale.order.line record A1
25
!record {model: sale.order.line, id: outgoing_sol_A1}:
27
company_id: base.main_company
29
order_id: outgoing_so_A
31
product_id: outgoing_product_A
32
product_uom: product.product_uom_unit
34
salesman_id: base.user_admin
39
Creating a sale.order.line record A2
41
!record {model: sale.order.line, id: outgoing_sol_A2}:
43
company_id: base.main_company
45
order_id: outgoing_so_A
47
product_id: outgoing_product_B
48
product_uom: product.product_uom_unit
50
salesman_id: base.user_admin
55
Creating a sale.order.line record A3
57
!record {model: sale.order.line, id: outgoing_sol_A3}:
59
company_id: base.main_company
61
order_id: outgoing_so_A
63
product_id: outgoing_product_C
64
product_uom: product.product_uom_unit
66
salesman_id: base.user_admin
71
Creating a sale.order record B
73
!record {model: sale.order, id: outgoing_so_B}:
78
company_id: base.main_company
79
date_order: '2011-04-13'
80
invoice_quantity: order
82
partner_id: outgoing_partner_A
83
partner_invoice_id: outgoing_address_A
84
partner_order_id: outgoing_address_A
85
partner_shipping_id: outgoing_address_A
86
picking_policy: direct
87
pricelist_id: product.list0
92
Creating a sale.order.line record B1
94
!record {model: sale.order.line, id: outgoing_sol_B1}:
96
company_id: base.main_company
98
order_id: outgoing_so_B
100
product_id: outgoing_product_A
101
product_uom: product.product_uom_unit
103
salesman_id: base.user_admin
108
Creating a sale.order.line record B2
110
!record {model: sale.order.line, id: outgoing_sol_B2}:
112
company_id: base.main_company
114
order_id: outgoing_so_B
116
product_id: outgoing_product_B
117
product_uom: product.product_uom_unit
119
salesman_id: base.user_admin
124
Creating a sale.order.line record B3
126
!record {model: sale.order.line, id: outgoing_sol_B3}:
128
company_id: base.main_company
130
order_id: outgoing_so_B
132
product_id: outgoing_product_C
133
product_uom: product.product_uom_unit
135
salesman_id: base.user_admin
140
I load the sale order references into context
142
!python {model: sale.order}: |
143
context['so'] = {'a': ref("outgoing_so_A"),
144
'b': ref("outgoing_so_B")}
146
I load the sale order lines references into context
148
!python {model: sale.order}: |
149
context['sol'] = {'a1': ref("outgoing_sol_A1"),
150
'a2': ref("outgoing_sol_A2"),
151
'a3': ref("outgoing_sol_A3"),
152
'b1': ref("outgoing_sol_B1"),
153
'b2': ref("outgoing_sol_B2"),
154
'b3': ref("outgoing_sol_B3")}
156
I load the product references into context
158
!python {model: sale.order}: |
159
context['product'] = {'a': ref("outgoing_product_A"),
160
'b': ref("outgoing_product_B"),
161
'c': ref("outgoing_product_C")}
163
I load the lot references into context
165
!python {model: sale.order}: |
166
context['lot'] = {'a': {'i': ref("outgoing_lot_Ai"),
167
's': ref("outgoing_lot_As")},
168
'b': {'i': ref("outgoing_lot_Bi"),
169
's': ref("outgoing_lot_Bs")}}
171
I load the address reference
173
!python {model: sale.order}: |
174
context['address'] = ref("outgoing_address_A")
176
I first validate both sale orders SOA and SOB
2
Creating a res.partner record
4
!record {model: res.partner, id: res_partner_a0}:
11
Creating a res.partner.address record
13
!record {model: res.partner.address, id: res_partner_address_0}:
14
partner_id: res_partner_a0
18
Creating a res.partner record
20
!record {model: res.partner, id: res_partner_b0}:
28
Creating a res.partner.address record
30
!record {model: res.partner.address, id: res_partner_address_1}:
31
partner_id: res_partner_b0
35
I create product template .
37
!record {model: product.template, id: product_template_p0}:
38
categ_id: product.cat0
42
procure_method: make_to_stock
46
uom_id: product.product_uom_unit
47
uom_po_id: product.product_uom_unit
50
Creating a product.product record
52
!record {model: product.product, id: product_product_p0}:
55
valuation: manual_periodic
60
product_tmpl_id: product_template_p0
63
Creating a sale.order record
65
!record {model: sale.order, id: sale_order_so0}:
69
company_id: base.main_company
70
date_order: '2011-04-13'
71
invoice_quantity: order
73
partner_id: res_partner_a0
74
partner_invoice_id: res_partner_address_0
75
partner_order_id: res_partner_address_0
76
partner_shipping_id: res_partner_address_0
77
picking_policy: direct
78
pricelist_id: product.list0
85
Creating a sale.order.line record
87
!record {model: sale.order.line, id: sale_order_line_p0}:
88
company_id: base.main_company
91
order_id: sale_order_so0
92
order_partner_id: res_partner_a0
94
product_id: product_product_p0
95
product_uom: product.product_uom_unit
97
salesman_id: base.user_admin
104
I validate the sale order
178
107
!python {model: sale.order}: |
180
109
wf_service = netsvc.LocalService("workflow")
181
wf_service.trg_validate(uid, 'sale.order', ref("outgoing_so_A"), 'order_validated', cr)
182
wf_service.trg_validate(uid, 'sale.order', ref("outgoing_so_B"), 'order_validated', cr)
183
wf_service.trg_validate(uid, 'sale.order', ref("outgoing_so_A"), 'order_confirm', cr)
184
wf_service.trg_validate(uid, 'sale.order', ref("outgoing_so_B"), 'order_confirm', cr)
186
I check two draft picking objects have been created
188
!python {model: stock.picking}: |
189
idsA = self.search(cr, uid, [('sale_id', '=', ref("outgoing_so_A")), ('state', '=', 'draft')], context=context)
190
idsB = self.search(cr, uid, [('sale_id', '=', ref("outgoing_so_B")), ('state', '=', 'draft')], context=context)
191
assert len(idsA) == 1, 'number of created draft picking for SO A is wrong, 1 - %s'%len(idsA)
192
assert len(idsB) == 1, 'number of created draft picking for SO B is wrong, 1 - %s'%len(idsB)
194
context.update({'out':{'a':idsA, 'b': idsB}})
196
I check the product and quantities in OUT draft picking objects
198
!python {model: stock.picking}: |
199
for obj in self.browse(cr, uid, context['out']['a']+context['out']['b'], context=context):
200
for move in obj.move_lines:
201
sol = move.sale_line_id
202
assert move.product_id.id == sol.product_id.id, 'product in out stock move for %s is wrong - %s - %s'%(sol.name, sol.product_id.name, move.product_id.name)
203
assert move.product_qty == sol.product_uom_qty, 'quantity in out stock move for %s is wrong - %s - %s'%(sol.name, sol.product_uom_qty, move.product_qty)
205
I open the create picking wizard for A
207
!python {model: stock.picking}: |
208
idsA = context['out']['a']
209
self.force_assign(cr, uid, idsA)
210
res = self.create_picking(cr, uid, idsA, context=context)
211
model = res['res_model']
214
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
216
I check the quantity rule "integrity_check_create_picking" #1: no negative quantity
218
!python {model: create.picking}: |
220
# create picking wizard -> product_moves_picking ('stock.move.memory.picking')
221
ids = context['wizard']['ids']
222
c = context['wizard']['c']
223
for obj in self.browse(cr, uid, ids, context=c):
224
for mem in obj.product_moves_picking:
225
mem.write({'quantity': -6}, context=c)
226
# validate the creation
227
self.do_create_picking(cr, uid, ids, context=c)
228
# we should get negative integrity status for each line
229
for obj in self.browse(cr, uid, ids, context=c):
230
for mem in obj.product_moves_picking:
231
assert mem.integrity_status == rule, 'integrity status is wrong for line %s - %s - %s'%(mem.line_number, rule, mem.integrity_status)
232
# there should be no picking ticket created
233
picking_ids = self.pool.get('stock.picking').search(cr, uid, [('backorder_id', 'in', context['out']['a'])], context=context)
234
assert len(picking_ids) == 0, 'picking ticket should have not been created for %s rule - 0 - %s'%(rule, len(picking_ids))
236
I check the quantity rule "integrity_check_create_picking" #2: empty picking
238
!python {model: create.picking}: |
240
# create picking wizard -> product_moves_picking ('stock.move.memory.picking')
241
ids = context['wizard']['ids']
242
c = context['wizard']['c']
243
for obj in self.browse(cr, uid, ids, context=c):
244
for mem in obj.product_moves_picking:
245
mem.write({'quantity': 0}, context=c)
246
# validate the creation
247
c.update({'yml_test': True})
248
self.do_create_picking(cr, uid, ids, context=c)
250
for obj in self.browse(cr, uid, ids, context=c):
251
for mem in obj.product_moves_picking:
252
assert mem.integrity_status == rule, 'integrity status is wrong for line %s - %s - %s'%(mem.line_number, rule, mem.integrity_status)
253
# there should be no picking ticket created
254
picking_ids = self.pool.get('stock.picking').search(cr, uid, [('backorder_id', 'in', context['out']['a'])], context=context)
255
assert len(picking_ids) == 0, 'picking ticket should have not been created for %s rule - 0 - %s'%(rule, len(picking_ids))
257
I check the production lot rule "integrity_check_prodlot" #3 a not lot managed product does not allow production lot
259
!python {model: create.picking}: |
260
rule = 'no_lot_needed'
261
# create picking wizard -> product_moves_picking ('stock.move.memory.picking')
262
ids = context['wizard']['ids']
263
c = context['wizard']['c']
265
self.select_all(cr, uid, ids, context=c)
266
for obj in self.browse(cr, uid, ids, context=c):
267
for mem in obj.product_moves_picking:
268
if mem.product_id.id == context['product']['c']:
269
mem.write({'prodlot_id': context['lot']['a']['i']}, context=c)
270
# validate the creation
271
self.do_create_picking(cr, uid, ids, context=c)
273
for obj in self.browse(cr, uid, ids, context=c):
274
for mem in obj.product_moves_picking:
275
if mem.product_id.id == context['product']['c']:
276
assert mem.integrity_status == rule, 'integrity status is wrong for line %s - %s - %s'%(mem.line_number, rule, mem.integrity_status)
277
# there should be no picking ticket created
278
picking_ids = self.pool.get('stock.picking').search(cr, uid, [('backorder_id', 'in', context['out']['a'])], context=context)
279
assert len(picking_ids) == 0, 'picking ticket should have not been created for %s rule - 0 - %s'%(rule, len(picking_ids))
281
I create a partial picking ticket 10, 20, 30 without production lots
283
!python {model: create.picking}: |
284
# create picking wizard -> product_moves_picking ('stock.move.memory.picking')
285
ids = context['wizard']['ids']
286
c = context['wizard']['c']
288
self.select_all(cr, uid, ids, context=c)
289
for obj in self.browse(cr, uid, ids, context=c):
290
for mem in obj.product_moves_picking:
291
if mem.product_id.id == context['product']['a']:
292
mem.write({'quantity': 10, 'prodlot_id': False}, context=c)
293
if mem.product_id.id == context['product']['b']:
294
mem.write({'quantity': 20, 'prodlot_id': False}, context=c)
295
if mem.product_id.id == context['product']['c']:
296
mem.write({'quantity': 30, 'prodlot_id': False}, context=c)
297
# validate the creation
298
self.do_create_picking(cr, uid, ids, context=c)
299
# there should be one picking ticket created
300
picking_ids = self.pool.get('stock.picking').search(cr, uid, [('backorder_id', 'in', context['out']['a'])], context=context)
301
# add the picking ticket id to the context structure
302
context.update({'pick': {'a': picking_ids}})
303
assert len(picking_ids) == 1, 'picking ticket should have been created - 1 - %s'%(len(picking_ids))
305
I open the validate picking wizard for A
307
!python {model: stock.picking}: |
308
idsA = context['pick']['a']
309
res = self.validate_picking(cr, uid, idsA, context=context)
310
model = res['res_model']
313
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
315
I check the production lot rule "integrity_check_prodlot" No production lot are selected, it should fail.
316
#1 a batch management product needs a standard production lot ***ONLY AT PICKING VALIDATION STAGE.
318
!python {model: create.picking}: |
320
# create picking wizard -> product_moves_picking ('stock.move.memory.picking')
321
ids = context['wizard']['ids']
322
c = context['wizard']['c']
324
self.select_all(cr, uid, ids, context=c)
325
# validate the creation
326
self.do_validate_picking(cr, uid, ids, context=c)
328
for obj in self.browse(cr, uid, ids, context=c):
329
for mem in obj.product_moves_picking:
330
if mem.product_id.id == context['product']['a']:
331
assert mem.integrity_status == rule, 'integrity status is wrong for line %s - %s - %s'%(mem.line_number, rule, mem.integrity_status)
332
# there should be no ppl created
333
ppl_ids = self.pool.get('stock.picking').search(cr, uid, [('previous_step_id', 'in', context['pick']['a'])], context=context)
334
assert len(ppl_ids) == 0, 'ppl should have not been created for %s rule - 0 - %s'%(rule, len(ppl_ids))
336
I check the production lot rule "integrity_check_prodlot" No production lot are selected, it should fail.
337
#2 a expiry date product needs an internal production lot ***ONLY AT PICKING VALIDATION STAGE
339
!python {model: create.picking}: |
340
rule = 'missing_date'
341
# create picking wizard -> product_moves_picking ('stock.move.memory.picking')
342
ids = context['wizard']['ids']
343
c = context['wizard']['c']
345
self.select_all(cr, uid, ids, context=c)
346
# validate the creation
347
self.do_validate_picking(cr, uid, ids, context=c)
349
for obj in self.browse(cr, uid, ids, context=c):
350
for mem in obj.product_moves_picking:
351
if mem.product_id.id == context['product']['b']:
352
assert mem.integrity_status == rule, 'integrity status is wrong for line %s - %s - %s'%(mem.line_number, rule, mem.integrity_status)
353
# there should be no ppl created
354
ppl_ids = self.pool.get('stock.picking').search(cr, uid, [('previous_step_id', 'in', context['pick']['a'])], context=context)
355
assert len(ppl_ids) == 0, 'ppl should have not been created for %s rule - 0 - %s'%(rule, len(ppl_ids))
357
I validate the picking
359
!python {model: create.picking}: |
360
# create picking wizard -> product_moves_picking ('stock.move.memory.picking')
361
ids = context['wizard']['ids']
362
c = context['wizard']['c']
364
self.deselect_all(cr, uid, ids, context=c)
365
self.select_all(cr, uid, ids, context=c)
366
for obj in self.browse(cr, uid, ids, context=c):
367
for mem in obj.product_moves_picking:
368
if mem.product_id.id == context['product']['a']:
369
mem.write({'prodlot_id': context['lot']['a']['s']}, context=c)
370
if mem.product_id.id == context['product']['b']:
371
mem.write({'prodlot_id': context['lot']['b']['i']}, context=c)
372
if mem.product_id.id == context['product']['c']:
373
mem.write({'prodlot_id': False}, context=c)
374
# validate the creation
375
self.copy_all(cr, uid, ids, context=c)
376
self.do_validate_picking(cr, uid, ids, context=c)
377
# there should be one ppl created
378
ppl_ids = self.pool.get('stock.picking').search(cr, uid, [('previous_step_id', 'in', context['pick']['a'])], context=context)
379
# add the ppl id to the context structure
380
context.update({'ppl': {'a': ppl_ids}})
381
assert len(ppl_ids) == 1, 'ppl should have been created - 1 - %s'%(len(ppl_ids))
383
I open the return product wizard for A
385
!python {model: stock.picking}: |
386
idsA = context['ppl']['a']
387
res = self.return_products(cr, uid, idsA, context=context)
388
model = res['res_model']
391
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
393
I check the production lot rule "integrity_check_return_products" set a negative value
394
#1 no negative values (<0)
396
!python {model: create.picking}: |
398
# return products -> product_moves_returnproducts ('stock.move.memory.returnproducts')
399
ids = context['wizard']['ids']
400
c = context['wizard']['c']
402
self.deselect_all(cr, uid, ids, context=c)
403
self.select_all(cr, uid, ids, context=c)
404
for obj in self.browse(cr, uid, ids, context=c):
405
for mem in obj.product_moves_returnproducts:
406
if mem.product_id.id == context['product']['c']:
407
mem.write({'qty_to_return': -10}, context=c)
408
# return the products
409
self.do_return_products(cr, uid, ids, context=c)
410
# negative value rule
411
for obj in self.browse(cr, uid, ids, context=c):
412
for mem in obj.product_moves_returnproducts:
413
if mem.product_id.id == context['product']['c']:
414
assert mem.integrity_status == rule, 'integrity status is wrong for line %s - %s - %s'%(mem.line_number, rule, mem.integrity_status)
415
# assert that nothing has been returned
416
vals = [90, 180, 270]
417
for sm in self.pool.get('stock.picking').browse(cr, uid, context['out']['a'][0], context=context).move_lines:
418
vals.remove(sm.product_qty)
419
assert not vals, 'vals is not empty - %s'%vals
421
I check the production lot rule "integrity_check_return_products" empty wizard
422
#2 at least one positive one (>0)
424
!python {model: create.picking}: |
426
# return products -> product_moves_returnproducts ('stock.move.memory.returnproducts')
427
ids = context['wizard']['ids']
428
c = context['wizard']['c']
430
self.deselect_all(cr, uid, ids, context=c)
431
# return the products
432
self.do_return_products(cr, uid, ids, context=c)
434
for obj in self.browse(cr, uid, ids, context=c):
435
for mem in obj.product_moves_returnproducts:
436
assert mem.integrity_status == rule, 'integrity status is wrong for line %s - %s - %s'%(mem.line_number, rule, mem.integrity_status)
437
# assert that nothing has been returned
438
vals = [90, 180, 270]
439
for sm in self.pool.get('stock.picking').browse(cr, uid, context['out']['a'][0], context=context).move_lines:
440
vals.remove(sm.product_qty)
441
assert not vals, 'vals is not empty - %s'%vals
443
I check the production lot rule "integrity_check_return_products" try to return more than available
444
#3 no more than available quantity
446
!python {model: create.picking}: |
447
rule = 'return_qty_too_much'
448
# return products -> product_moves_returnproducts ('stock.move.memory.returnproducts')
449
ids = context['wizard']['ids']
450
c = context['wizard']['c']
452
self.deselect_all(cr, uid, ids, context=c)
453
# I set too much for the product c
454
for obj in self.browse(cr, uid, ids, context=c):
455
for mem in obj.product_moves_returnproducts:
456
if mem.product_id.id == context['product']['c']:
457
mem.write({'qty_to_return': 5000}, context=c)
458
# return the products
459
self.do_return_products(cr, uid, ids, context=c)
461
for obj in self.browse(cr, uid, ids, context=c):
462
for mem in obj.product_moves_returnproducts:
463
if mem.product_id.id == context['product']['c']:
464
assert mem.integrity_status == rule, 'integrity status is wrong for line %s - %s - %s'%(mem.line_number, rule, mem.integrity_status)
465
# assert that nothing has been returned
466
vals = [90, 180, 270]
467
for sm in self.pool.get('stock.picking').browse(cr, uid, context['out']['a'][0], context=context).move_lines:
468
vals.remove(sm.product_qty)
469
assert not vals, 'vals is not empty - %s'%vals
473
!python {model: create.picking}: |
474
# return products -> product_moves_returnproducts ('stock.move.memory.returnproducts')
475
ids = context['wizard']['ids']
476
c = context['wizard']['c']
478
self.deselect_all(cr, uid, ids, context=c)
479
# I set too much for the product c
480
for obj in self.browse(cr, uid, ids, context=c):
481
for mem in obj.product_moves_returnproducts:
482
if mem.product_id.id == context['product']['a']:
483
mem.write({'qty_to_return': 5}, context=c)
484
# return the products
485
self.do_return_products(cr, uid, ids, context=c)
486
# assert that 5 have been returned
487
vals = [95, 180, 270]
488
for sm in self.pool.get('stock.picking').browse(cr, uid, context['out']['a'][0], context=context).move_lines:
489
vals.remove(sm.product_qty)
490
assert not vals, 'vals is not empty - %s'%vals
492
I open the pack ppl wizard for A
494
!python {model: stock.picking}: |
495
idsA = context['ppl']['a']
496
res = self.ppl(cr, uid, idsA, context=context)
497
model = res['res_model']
500
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
502
I check the sequence rules "integrity_check_sequences" (0, 1)
503
# rule #1, the first from value must be equal to 1
505
!python {model: create.picking}: |
507
# ppl step1 -> product_moves_ppl ('stock.move.memory.ppl')
508
ids = context['wizard']['ids']
509
c = context['wizard']['c']
510
for obj in self.browse(cr, uid, ids, context=c):
511
for mem in obj.product_moves_ppl:
512
if mem.product_id.id == context['product']['c']:
513
mem.write({'from_pack': 0, 'to_pack': 1}, context=c)
514
# validate first step
515
self.copy_all(cr, uid, ids, context=c)
516
self.do_ppl1(cr, uid, ids, context=c)
517
# negative value rule
518
for obj in self.browse(cr, uid, ids, context=c):
519
for mem in obj.product_moves_ppl:
520
if mem.product_id.id == context['product']['c']:
521
assert mem.integrity_status == rule, 'integrity status is wrong for line %s - %s - %s'%(mem.line_number, rule, mem.integrity_status)
523
I open the split wizard for product C
525
!python {model: create.picking}: |
527
# ppl step1 -> product_moves_ppl ('stock.move.memory.ppl')
528
ids = context['wizard']['ids']
529
c = context['wizard']['c']
530
for obj in self.browse(cr, uid, ids, context=c):
531
for mem in obj.product_moves_ppl:
532
if mem.product_id.id == context['product']['c']:
534
res = mem.split(context=c)
535
model = res['res_model']
538
context['split'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
540
I split the line with product C, should be 30 and I split it on 2 and 28.
542
!python {model: split.memory.move}: |
544
# split move -> split_memory_move ('split.memory.move')
545
ids = context['split']['ids']
546
c = context['split']['c']
547
self.write(cr, uid, ids, {'quantity': 2}, context=c)
548
self.split(cr, uid, ids, context=c)
550
I check the sequence rules "integrity_check_sequences"
551
# rule #2: if from[i] == from[i-1] -> to[i] == to[i-1]
553
!python {model: create.picking}: |
557
# ppl step1 -> product_moves_ppl ('stock.move.memory.ppl')
558
ids = context['wizard']['ids']
559
c = context['wizard']['c']
560
for obj in self.browse(cr, uid, ids, context=c):
561
for mem in obj.product_moves_ppl:
562
if mem.product_id.id == context['product']['c']:
564
mem.write({'from_pack': seq[0], 'to_pack': seq[1]}, context=c)
566
self.copy_all(cr, uid, ids, context=c)
567
self.do_ppl1(cr, uid, ids, context=c)
568
# check the validation results
569
for obj in self.browse(cr, uid, ids, context=c):
570
for mem in obj.product_moves_ppl:
571
if mem.product_id.id == context['product']['c']:
572
if mem.integrity_status in rules:
573
rules.remove(mem.integrity_status)
574
# assert all rules have been reached
575
assert not rules, 'all rules are not triggered - %s - %s'%([], rules)
577
I check the sequence rules "integrity_check_sequences"
578
# rule #2: if from[i] == from[i-1] -> to[i] == to[i-1]
580
!python {model: create.picking}: |
584
# ppl step1 -> product_moves_ppl ('stock.move.memory.ppl')
585
ids = context['wizard']['ids']
586
c = context['wizard']['c']
587
for obj in self.browse(cr, uid, ids, context=c):
588
for mem in obj.product_moves_ppl:
589
if mem.product_id.id == context['product']['c']:
591
mem.write({'from_pack': seq[0], 'to_pack': seq[1]}, context=c)
593
self.copy_all(cr, uid, ids, context=c)
594
self.do_ppl1(cr, uid, ids, context=c)
595
# check the validation results
596
for obj in self.browse(cr, uid, ids, context=c):
597
for mem in obj.product_moves_ppl:
598
if mem.product_id.id == context['product']['c']:
599
if mem.integrity_status in rules:
600
rules.remove(mem.integrity_status)
601
# assert all rules have been reached
602
assert not rules, 'all rules are not triggered - %s - %s'%([], rules)
604
I check the sequence rules "integrity_check_sequences"
605
# rule #3: if from[i] != from[i-1] -> from[i] == to[i-1]+1
607
!python {model: create.picking}: |
611
# ppl step1 -> product_moves_ppl ('stock.move.memory.ppl')
612
ids = context['wizard']['ids']
613
c = context['wizard']['c']
614
for obj in self.browse(cr, uid, ids, context=c):
615
for mem in obj.product_moves_ppl:
616
if mem.product_id.id == context['product']['c']:
618
mem.write({'from_pack': seq[0], 'to_pack': seq[1]}, context=c)
620
self.copy_all(cr, uid, ids, context=c)
621
self.do_ppl1(cr, uid, ids, context=c)
622
# check the validation results
623
for obj in self.browse(cr, uid, ids, context=c):
624
for mem in obj.product_moves_ppl:
625
if mem.product_id.id == context['product']['c']:
626
if mem.integrity_status in rules:
627
rules.remove(mem.integrity_status)
628
# assert all rules have been reached
629
assert not rules, 'all rules are not triggered - %s - %s'%([], rules)
631
I check the sequence rules "integrity_check_sequences"
632
# rule #3: if from[i] != from[i-1] -> from[i] == to[i-1]+1
634
!python {model: create.picking}: |
638
# ppl step1 -> product_moves_ppl ('stock.move.memory.ppl')
639
ids = context['wizard']['ids']
640
c = context['wizard']['c']
641
for obj in self.browse(cr, uid, ids, context=c):
642
for mem in obj.product_moves_ppl:
643
if mem.product_id.id == context['product']['c']:
645
mem.write({'from_pack': seq[0], 'to_pack': seq[1]}, context=c)
647
self.copy_all(cr, uid, ids, context=c)
648
self.do_ppl1(cr, uid, ids, context=c)
649
# check the validation results
650
for obj in self.browse(cr, uid, ids, context=c):
651
for mem in obj.product_moves_ppl:
652
if mem.product_id.id == context['product']['c']:
653
if mem.integrity_status in rules:
654
rules.remove(mem.integrity_status)
655
# assert all rules have been reached
656
assert not rules, 'all rules are not triggered - %s - %s'%([], rules)
658
I check the sequence rules "integrity_check_sequences"
659
# rule #3: if from[i] != from[i-1] -> from[i] == to[i-1]+1
661
!python {model: create.picking}: |
665
# ppl step1 -> product_moves_ppl ('stock.move.memory.ppl')
666
ids = context['wizard']['ids']
667
c = context['wizard']['c']
668
for obj in self.browse(cr, uid, ids, context=c):
669
for mem in obj.product_moves_ppl:
670
if mem.product_id.id == context['product']['c']:
672
mem.write({'from_pack': seq[0], 'to_pack': seq[1]}, context=c)
674
self.copy_all(cr, uid, ids, context=c)
675
self.do_ppl1(cr, uid, ids, context=c)
676
# check the validation results
677
for obj in self.browse(cr, uid, ids, context=c):
678
for mem in obj.product_moves_ppl:
679
if mem.product_id.id == context['product']['c']:
680
if mem.integrity_status in rules:
681
rules.remove(mem.integrity_status)
682
# assert all rules have been reached
683
assert not rules, 'all rules are not triggered - %s - %s'%([], rules)
685
I check the sequence rules "integrity_check_sequences"
686
# rule #4: to[i] >= from[i]
688
!python {model: create.picking}: |
689
rules = ['overlap','to_smaller_than_from']
692
# ppl step1 -> product_moves_ppl ('stock.move.memory.ppl')
693
ids = context['wizard']['ids']
694
c = context['wizard']['c']
695
for obj in self.browse(cr, uid, ids, context=c):
696
for mem in obj.product_moves_ppl:
697
if mem.product_id.id == context['product']['c']:
699
mem.write({'from_pack': seq[0], 'to_pack': seq[1]}, context=c)
701
self.copy_all(cr, uid, ids, context=c)
702
self.do_ppl1(cr, uid, ids, context=c)
703
# check the validation results
704
for obj in self.browse(cr, uid, ids, context=c):
705
for mem in obj.product_moves_ppl:
706
if mem.product_id.id == context['product']['c']:
707
if mem.integrity_status in rules:
708
rules.remove(mem.integrity_status)
709
# assert all rules have been reached
710
assert not rules, 'all rules are not triggered - %s - %s'%([], rules)
712
I check the sequence rules "integrity_check_sequences"
713
# rule #3: if from[i] != from[i-1] -> from[i] == to[i-1]+1
715
!python {model: create.picking}: |
719
# ppl step1 -> product_moves_ppl ('stock.move.memory.ppl')
720
ids = context['wizard']['ids']
721
c = context['wizard']['c']
722
for obj in self.browse(cr, uid, ids, context=c):
723
for mem in obj.product_moves_ppl:
724
if mem.product_id.id == context['product']['c']:
726
mem.write({'from_pack': seq[0], 'to_pack': seq[1]}, context=c)
728
self.copy_all(cr, uid, ids, context=c)
729
self.do_ppl1(cr, uid, ids, context=c)
730
# check the validation results
731
for obj in self.browse(cr, uid, ids, context=c):
732
for mem in obj.product_moves_ppl:
733
if mem.product_id.id == context['product']['c']:
734
if mem.integrity_status in rules:
735
rules.remove(mem.integrity_status)
736
# assert all rules have been reached
737
assert not rules, 'all rules are not triggered - %s - %s'%([], rules)
739
I open ppl2 wizard - for prod C, put 2 in 2,3 and 28 in 4,5. the other products are put in 1,1
741
!python {model: create.picking}: |
743
# ppl step1 -> product_moves_ppl ('stock.move.memory.ppl')
744
ids = context['wizard']['ids']
745
c = context['wizard']['c']
746
for obj in self.browse(cr, uid, ids, context=c):
747
for mem in obj.product_moves_ppl:
748
if mem.product_id.id == context['product']['c']:
749
if mem.quantity == 28:
750
mem.write({'from_pack': 4, 'to_pack': 5}, context=c)
751
elif mem.quantity == 2:
752
mem.write({'from_pack': 2, 'to_pack': 3}, context=c)
754
self.copy_all(cr, uid, ids, context=c)
755
res = self.do_ppl1(cr, uid, ids, context=c)
756
model = res['res_model']
759
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
761
I check the weight rules "integrity_check_weight"
762
# rule #1: weight must exist if not quick flow type
764
!python {model: create.picking}: |
765
rule = 'missing_weight'
766
# ppl step2 -> product_moves_families ('stock.move.memory.families')
767
ids = context['wizard']['ids']
768
c = context['wizard']['c']
770
self.do_ppl2(cr, uid, ids, context=c)
771
# check the validation results
772
for obj in self.browse(cr, uid, ids, context=c):
773
for mem in obj.product_moves_families:
774
assert mem.integrity_status == rule, 'integrity status is wrong - %s - %s'%(rule, mem.integrity_status)
776
set weight and validate ppl2 step
778
!python {model: create.picking}: |
779
# ppl step2 -> product_moves_families ('stock.move.memory.families')
780
ids = context['wizard']['ids']
781
c = context['wizard']['c']
782
for obj in self.browse(cr, uid, ids, context=c):
783
for mem in obj.product_moves_families:
784
mem.write({'weight': 10}, context=c)
786
self.do_ppl2(cr, uid, ids, context=c)
788
I check a draft shipment has been created
790
!python {model: shipment}: |
791
ids = self.search(cr, uid, [('address_id', '=', context['address']), ('state', '=', 'draft')], context=context)
792
assert len(ids) == 1, 'number of created shipment is wrong, 1 - %s'%len(ids)
794
context.update({'draft_shipment': ids})
796
I bring products from SO B in quick mode into the shipment. I open the create picking wizard for B
798
!python {model: stock.picking}: |
799
idsA = context['out']['b']
800
self.force_assign(cr, uid, idsA)
801
res = self.create_picking(cr, uid, idsA, context=context)
802
model = res['res_model']
805
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
807
I create a partial picking ticket containing all products and production lots
809
!python {model: create.picking}: |
810
# create picking wizard -> product_moves_picking ('stock.move.memory.picking')
811
ids = context['wizard']['ids']
812
c = context['wizard']['c']
814
self.select_all(cr, uid, ids, context=c)
815
# set the production lots
816
for obj in self.browse(cr, uid, ids, context=c):
817
for mem in obj.product_moves_picking:
818
if mem.product_id.id == context['product']['a']:
819
mem.write({'prodlot_id': context['lot']['a']['s']}, context=c)
820
if mem.product_id.id == context['product']['b']:
821
mem.write({'prodlot_id': context['lot']['b']['i']}, context=c)
822
if mem.product_id.id == context['product']['c']:
823
mem.write({'prodlot_id': False}, context=c)
824
# validate the creation
825
self.do_create_picking(cr, uid, ids, context=c)
826
# there should be one picking ticket created
827
picking_ids = self.pool.get('stock.picking').search(cr, uid, [('backorder_id', 'in', context['out']['b'])], context=context)
828
# add the picking ticket id to the context structure
829
context.update({'pick': {'b': picking_ids}})
830
assert len(picking_ids) == 1, 'picking ticket should have been created - 1bis - %s'%(len(picking_ids))
834
!python {model: stock.picking}: |
835
ids = context['pick']['b']
836
self.write(cr, uid, ids, {'flow_type': 'quick',}, context=context)
838
I open the validate picking wizard for B
840
!python {model: stock.picking}: |
841
ids = context['pick']['b']
842
res = self.validate_picking(cr, uid, ids, context=context)
843
model = res['res_model']
846
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
848
I validate the picking
850
!python {model: create.picking}: |
851
# create picking wizard -> product_moves_picking ('stock.move.memory.picking')
852
ids = context['wizard']['ids']
853
c = context['wizard']['c']
855
self.deselect_all(cr, uid, ids, context=c)
856
self.select_all(cr, uid, ids, context=c)
857
# validate the creation
858
self.copy_all(cr, uid, ids, context=c)
859
self.do_validate_picking(cr, uid, ids, context=c)
860
# there should be one ppl created
861
ppl_ids = self.pool.get('stock.picking').search(cr, uid, [('previous_step_id', 'in', context['pick']['b'])], context=context)
862
# add the ppl id to the context structure
863
context.update({'ppl': {'b': ppl_ids}})
864
assert len(ppl_ids) == 1, 'ppl should have been created - 1 - %s'%(len(ppl_ids))
866
I open the return product to stock wizard
868
!python {model: shipment}: |
869
ids = context['draft_shipment']
870
res = self.return_packs(cr, uid, ids, context=context)
871
model = res['res_model']
874
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
876
I check rules from "integrity_check_packs"
877
#1 no negative values (<0)
879
!python {model: shipment.wizard}: |
881
# return products to stock -> product_moves_shipment_returnpacks ('stock.move.memory.shipment.returnpacks')
882
ids = context['wizard']['ids']
883
c = context['wizard']['c']
885
self.deselect_all(cr, uid, ids, context=c)
886
self.select_all(cr, uid, ids, context=c)
887
for obj in self.browse(cr, uid, ids, context=c):
888
for mem in obj.product_moves_shipment_returnpacks:
889
mem.write({'selected_number': -10}, context=c)
890
# return the products
891
self.do_return_packs(cr, uid, ids, context=c)
892
# negative value rule
893
for obj in self.browse(cr, uid, ids, context=c):
894
for mem in obj.product_moves_shipment_returnpacks:
895
assert mem.integrity_status == rule, 'integrity status is wrong - %s - %s'%(rule, mem.integrity_status)
896
# assert that nothing has been returned
897
vals = [95, 180, 270]
898
for sm in self.pool.get('stock.picking').browse(cr, uid, context['out']['a'][0], context=context).move_lines:
899
vals.remove(sm.product_qty)
900
assert not vals, 'vals is not empty - %s'%vals
902
for sm in self.pool.get('stock.picking').browse(cr, uid, context['out']['b'][0], context=context).move_lines:
903
vals.remove(sm.product_qty)
904
assert not vals, 'vals is not empty - %s'%vals
906
I check rules from "integrity_check_packs"
907
#2 at least one positive one (>0)
909
!python {model: shipment.wizard}: |
911
# return products to stock -> product_moves_shipment_returnpacks ('stock.move.memory.shipment.returnpacks')
912
ids = context['wizard']['ids']
913
c = context['wizard']['c']
915
self.deselect_all(cr, uid, ids, context=c)
916
# return the products
917
self.do_return_packs(cr, uid, ids, context=c)
919
for obj in self.browse(cr, uid, ids, context=c):
920
for mem in obj.product_moves_shipment_returnpacks:
921
assert mem.integrity_status == rule, 'integrity status is wrong - %s - %s'%(rule, mem.integrity_status)
922
# assert that nothing has been returned
923
vals = [95, 180, 270]
924
for sm in self.pool.get('stock.picking').browse(cr, uid, context['out']['a'][0], context=context).move_lines:
925
vals.remove(sm.product_qty)
926
assert not vals, 'vals is not empty - %s'%vals
928
for sm in self.pool.get('stock.picking').browse(cr, uid, context['out']['b'][0], context=context).move_lines:
929
vals.remove(sm.product_qty)
930
assert not vals, 'vals is not empty - %s'%vals
932
I check rules from "integrity_check_packs"
933
#3 no more than available quantity #packs
935
!python {model: shipment.wizard}: |
936
rule = 'return_qty_too_much'
937
# return products to stock -> product_moves_shipment_returnpacks ('stock.move.memory.shipment.returnpacks')
938
ids = context['wizard']['ids']
939
c = context['wizard']['c']
941
self.deselect_all(cr, uid, ids, context=c)
942
for obj in self.browse(cr, uid, ids, context=c):
943
for mem in obj.product_moves_shipment_returnpacks:
944
mem.write({'selected_number': 9999}, context=c)
945
# return the products
946
self.do_return_packs(cr, uid, ids, context=c)
948
for obj in self.browse(cr, uid, ids, context=c):
949
for mem in obj.product_moves_shipment_returnpacks:
950
assert mem.integrity_status == rule, 'integrity status is wrong - %s - %s'%(rule, mem.integrity_status)
951
# assert that nothing has been returned
952
vals = [95, 180, 270]
953
for sm in self.pool.get('stock.picking').browse(cr, uid, context['out']['a'][0], context=context).move_lines:
954
vals.remove(sm.product_qty)
955
assert not vals, 'vals is not empty - %s'%vals
957
for sm in self.pool.get('stock.picking').browse(cr, uid, context['out']['b'][0], context=context).move_lines:
958
vals.remove(sm.product_qty)
959
assert not vals, 'vals is not empty - %s'%vals
961
I return 1 pack for the sequence (4,5) - 1 pack 4,5 contains 14 prodC
963
!python {model: shipment.wizard}: |
964
# return products to stock -> product_moves_shipment_returnpacks ('stock.move.memory.shipment.returnpacks')
965
ids = context['wizard']['ids']
966
c = context['wizard']['c']
968
self.deselect_all(cr, uid, ids, context=c)
969
for obj in self.browse(cr, uid, ids, context=c):
970
for mem in obj.product_moves_shipment_returnpacks:
971
if mem.from_pack == 4:
972
mem.write({'selected_number': 1}, context=c)
973
# return the products
974
self.do_return_packs(cr, uid, ids, context=c)
975
# assert that nothing has been returned
976
vals = [95, 180, 284] # 284 because we returned 14
977
for sm in self.pool.get('stock.picking').browse(cr, uid, context['out']['a'][0], context=context).move_lines:
978
vals.remove(sm.product_qty)
979
assert not vals, 'vals is not empty - %s'%vals
981
for sm in self.pool.get('stock.picking').browse(cr, uid, context['out']['b'][0], context=context).move_lines:
982
vals.remove(sm.product_qty)
983
assert not vals, 'vals is not empty - %s'%vals
985
I open the create shipment wizard
987
!python {model: shipment}: |
988
ids = context['draft_shipment']
989
res = self.create_shipment(cr, uid, ids, context=context)
990
model = res['res_model']
993
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
995
I check rules from "integrity_check_packs"
996
#1 no negative values (<0)
998
!python {model: shipment.wizard}: |
1000
# create shipment -> product_moves_shipment_create ('stock.move.memory.shipment.create')
1001
ids = context['wizard']['ids']
1002
c = context['wizard']['c']
1004
self.deselect_all(cr, uid, ids, context=c)
1005
self.select_all(cr, uid, ids, context=c)
1006
for obj in self.browse(cr, uid, ids, context=c):
1007
for mem in obj.product_moves_shipment_create:
1008
mem.write({'selected_number': -10}, context=c)
1010
c.update({'yml_test': True})
1011
self.do_create_shipment(cr, uid, ids, context=c)
1012
# negative value rule
1013
for obj in self.browse(cr, uid, ids, context=c):
1014
for mem in obj.product_moves_shipment_create:
1015
assert mem.integrity_status == rule, 'integrity status is wrong - %s - %s'%(rule, mem.integrity_status)
1016
# assert that no shipment has been created
1017
shipment_ids = self.pool.get('shipment').search(cr, uid, [('parent_id', 'in', context['draft_shipment'])], context=context)
1018
assert len(shipment_ids) == 0, 'shipment should have not been created for %s rule - 0 - %s'%(rule, len(shipment_ids))
1020
I check rules from "integrity_check_packs"
1021
#2 at least one positive one (>0)
1023
!python {model: shipment.wizard}: |
1025
# create shipment -> product_moves_shipment_create ('stock.move.memory.shipment.create')
1026
ids = context['wizard']['ids']
1027
c = context['wizard']['c']
1029
self.deselect_all(cr, uid, ids, context=c)
1031
c.update({'yml_test': True})
1032
self.do_create_shipment(cr, uid, ids, context=c)
1034
for obj in self.browse(cr, uid, ids, context=c):
1035
for mem in obj.product_moves_shipment_create:
1036
assert mem.integrity_status == rule, 'integrity status is wrong - %s - %s'%(rule, mem.integrity_status)
1037
# assert that no shipment has been created
1038
shipment_ids = self.pool.get('shipment').search(cr, uid, [('parent_id', 'in', context['draft_shipment'])], context=context)
1039
assert len(shipment_ids) == 0, 'shipment should have not been created for %s rule - 0 - %s'%(rule, len(shipment_ids))
1041
I check rules from "integrity_check_packs"
1042
#3 no more than available quantity #packs
1044
!python {model: shipment.wizard}: |
1045
rule = 'return_qty_too_much'
1046
# create shipment -> product_moves_shipment_create ('stock.move.memory.shipment.create')
1047
ids = context['wizard']['ids']
1048
c = context['wizard']['c']
1050
self.deselect_all(cr, uid, ids, context=c)
1051
for obj in self.browse(cr, uid, ids, context=c):
1052
for mem in obj.product_moves_shipment_create:
1053
mem.write({'selected_number': 9999}, context=c)
1055
c.update({'yml_test': True})
1056
self.do_create_shipment(cr, uid, ids, context=c)
1058
for obj in self.browse(cr, uid, ids, context=c):
1059
for mem in obj.product_moves_shipment_create:
1060
assert mem.integrity_status == rule, 'integrity status is wrong - %s - %s'%(rule, mem.integrity_status)
1061
# assert that no shipment has been created
1062
shipment_ids = self.pool.get('shipment').search(cr, uid, [('parent_id', 'in', context['draft_shipment'])], context=context)
1063
assert len(shipment_ids) == 0, 'shipment should have not been created for %s rule - 0 - %s'%(rule, len(shipment_ids))
1065
I create a shipment with 1 pack so_a 1,1, 1 pack so_b 1,1
1066
# present configuration of packs
1072
!python {model: shipment.wizard}: |
1073
# create shipment -> product_moves_shipment_create ('stock.move.memory.shipment.create')
1074
ids = context['wizard']['ids']
1075
c = context['wizard']['c']
1077
self.deselect_all(cr, uid, ids, context=c)
1078
for obj in self.browse(cr, uid, ids, context=c):
1079
for mem in obj.product_moves_shipment_create:
1080
if mem.sale_order_id.id == context['so']['a'] and mem.from_pack == 1:
1081
mem.write({'selected_number': 1}, context=c)
1082
if mem.sale_order_id.id == context['so']['b']:
1083
mem.write({'selected_number': 1}, context=c)
1085
c.update({'yml_test': True})
1086
self.do_create_shipment(cr, uid, ids, context=c)
1087
# assert a shipment has been created
1088
shipment_ids = self.pool.get('shipment').search(cr, uid, [('parent_id', 'in', context['draft_shipment'])], context=context)
1089
assert len(shipment_ids) == 1, 'shipment should have been created - 1 - %s'%(len(shipment_ids))
1091
context.update({'shipment1': shipment_ids})
1093
I open the create shipment wizard
1095
!python {model: shipment}: |
1096
ids = context['draft_shipment']
1097
res = self.create_shipment(cr, uid, ids, context=context)
1098
model = res['res_model']
1101
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
1103
I create a second shipment with the rest
1104
# present configuration of packs
1108
!python {model: shipment.wizard}: |
1109
# create shipment -> product_moves_shipment_create ('stock.move.memory.shipment.create')
1110
ids = context['wizard']['ids']
1111
c = context['wizard']['c']
1113
self.select_all(cr, uid, ids, context=c)
1115
c.update({'yml_test': True})
1116
self.do_create_shipment(cr, uid, ids, context=c)
1117
# assert a shipment has been created
1118
shipment_ids = self.pool.get('shipment').search(cr, uid, [('parent_id', 'in', context['draft_shipment'])], context=context)
1119
assert len(shipment_ids) == 2, 'shipment should have been created - 2 - %s'%(len(shipment_ids))
1120
# save shipment id - keep the max (last) id
1121
context.update({'shipment2': [max(shipment_ids)]})
1123
I open the return from shipment wizard for shipment2
1125
!python {model: shipment}: |
1126
ids = context['shipment2']
1127
res = self.return_packs_from_shipment(cr, uid, ids, context=context)
1128
model = res['res_model']
1131
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
1133
I check rules from "integrity_check_return_packs_from_shipment" (3,2)
1134
#1: sfrom <= sto // integrity of selected sequence
1135
# present configuration of packs
1139
!python {model: shipment.wizard}: |
1140
rule = 'to_smaller_than_from'
1141
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1142
ids = context['wizard']['ids']
1143
c = context['wizard']['c']
1145
self.deselect_all(cr, uid, ids, context=c)
1146
for obj in self.browse(cr, uid, ids, context=c):
1147
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1148
if mem.from_pack == 2:
1149
mem.write({'return_from': 3, 'return_to': 2}, context=c)
1151
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1153
for obj in self.browse(cr, uid, ids, context=c):
1154
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1155
if mem.from_pack == 2:
1156
assert mem.integrity_status == rule, 'integrity status is wrong - %s - %s'%(rule, mem.integrity_status)
1158
I check rules from "integrity_check_return_packs_from_shipment" (1,2)
1159
#2: (sfrom >= from) and (sto <= to) // in the initial range
1160
# present configuration of packs
1164
!python {model: shipment.wizard}: |
1165
rule = 'seq_out_of_range'
1166
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1167
ids = context['wizard']['ids']
1168
c = context['wizard']['c']
1170
self.deselect_all(cr, uid, ids, context=c)
1171
for obj in self.browse(cr, uid, ids, context=c):
1172
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1173
if mem.from_pack == 2:
1174
mem.write({'return_from': 1, 'return_to': 2}, context=c)
1176
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1178
for obj in self.browse(cr, uid, ids, context=c):
1179
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1180
if mem.from_pack == 2:
1181
assert mem.integrity_status == rule, 'integrity status is wrong - %s - %s'%(rule, mem.integrity_status)
1183
I check rules from "integrity_check_return_packs_from_shipment" (0,1)
1184
#2: (sfrom >= from) and (sto <= to) // in the initial range
1185
# present configuration of packs
1189
!python {model: shipment.wizard}: |
1190
rule = 'seq_out_of_range'
1191
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1192
ids = context['wizard']['ids']
1193
c = context['wizard']['c']
1195
self.deselect_all(cr, uid, ids, context=c)
1196
for obj in self.browse(cr, uid, ids, context=c):
1197
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1198
if mem.from_pack == 2:
1199
mem.write({'return_from': 0, 'return_to': 1}, context=c)
1201
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1203
for obj in self.browse(cr, uid, ids, context=c):
1204
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1205
if mem.from_pack == 2:
1206
assert mem.integrity_status == rule, 'integrity status is wrong - %s - %s'%(rule, mem.integrity_status)
1208
I check rules from "integrity_check_return_packs_from_shipment" (3,4)
1209
#2: (sfrom >= from) and (sto <= to) // in the initial range
1210
# present configuration of packs
1214
!python {model: shipment.wizard}: |
1215
rule = 'seq_out_of_range'
1216
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1217
ids = context['wizard']['ids']
1218
c = context['wizard']['c']
1220
self.deselect_all(cr, uid, ids, context=c)
1221
for obj in self.browse(cr, uid, ids, context=c):
1222
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1223
if mem.from_pack == 2:
1224
mem.write({'return_from': 3, 'return_to': 4}, context=c)
1226
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1228
for obj in self.browse(cr, uid, ids, context=c):
1229
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1230
if mem.from_pack == 2:
1231
assert mem.integrity_status == rule, 'integrity status is wrong - %s - %s'%(rule, mem.integrity_status)
1233
I check rules from "integrity_check_return_packs_from_shipment" (5,6)
1234
#2: (sfrom >= from) and (sto <= to) // in the initial range
1235
# present configuration of packs
1239
!python {model: shipment.wizard}: |
1240
rule = 'seq_out_of_range'
1241
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1242
ids = context['wizard']['ids']
1243
c = context['wizard']['c']
1245
self.deselect_all(cr, uid, ids, context=c)
1246
for obj in self.browse(cr, uid, ids, context=c):
1247
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1248
if mem.from_pack == 2:
1249
mem.write({'return_from': 5, 'return_to': 6}, context=c)
1251
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1253
for obj in self.browse(cr, uid, ids, context=c):
1254
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1255
if mem.from_pack == 2:
1256
assert mem.integrity_status == rule, 'integrity status is wrong - %s - %s'%(rule, mem.integrity_status)
1258
I split the line so_a 2,3
1260
!python {model: shipment.wizard}: |
1261
rule = 'to_smaller_than_from'
1262
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1263
ids = context['wizard']['ids']
1264
c = context['wizard']['c']
1265
for obj in self.browse(cr, uid, ids, context=c):
1266
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1267
if mem.from_pack == 2:
1268
mem.split(context=c)
1270
I check rules from "integrity_check_return_packs_from_shipment"
1271
#2: (sfrom >= from) and (sto <= to) // in the initial range
1272
# present configuration of packs
1274
# so_a ppl_1 2,3 (split)
1277
!python {model: shipment.wizard}: |
1278
rules = ['seq_out_of_range','empty']
1279
sequences = [(1,2),(3,3)]
1280
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1281
ids = context['wizard']['ids']
1282
c = context['wizard']['c']
1284
self.deselect_all(cr, uid, ids, context=c)
1285
for obj in self.browse(cr, uid, ids, context=c):
1286
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1287
if mem.from_pack == 2:
1288
seq = sequences.pop()
1289
mem.write({'return_from': seq[0], 'return_to': seq[1]}, context=c)
1291
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1293
for obj in self.browse(cr, uid, ids, context=c):
1294
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1295
if mem.from_pack == 2:
1296
assert mem.integrity_status in rules, 'integrity status is wrong - %s - %s'%(rules, mem.integrity_status)
1298
I check rules from "integrity_check_return_packs_from_shipment"
1299
#2: (sfrom >= from) and (sto <= to) // in the initial range
1300
# present configuration of packs
1302
# so_a ppl_1 2,3 (split)
1305
!python {model: shipment.wizard}: |
1306
rules = ['seq_out_of_range','empty']
1307
sequences = [(0,1),(3,3)]
1308
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1309
ids = context['wizard']['ids']
1310
c = context['wizard']['c']
1312
self.deselect_all(cr, uid, ids, context=c)
1313
for obj in self.browse(cr, uid, ids, context=c):
1314
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1315
if mem.from_pack == 2:
1316
seq = sequences.pop()
1317
mem.write({'return_from': seq[0], 'return_to': seq[1]}, context=c)
1319
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1321
for obj in self.browse(cr, uid, ids, context=c):
1322
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1323
if mem.from_pack == 2:
1324
assert mem.integrity_status in rules, 'integrity status is wrong - %s - %s'%(rules, mem.integrity_status)
1326
I check rules from "integrity_check_return_packs_from_shipment"
1327
#2: (sfrom >= from) and (sto <= to) // in the initial range
1328
# present configuration of packs
1330
# so_a ppl_1 2,3 (split)
1333
!python {model: shipment.wizard}: |
1334
rules = ['seq_out_of_range','empty']
1335
sequences = [(2,2),(3,4)]
1336
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1337
ids = context['wizard']['ids']
1338
c = context['wizard']['c']
1340
self.deselect_all(cr, uid, ids, context=c)
1341
for obj in self.browse(cr, uid, ids, context=c):
1342
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1343
if mem.from_pack == 2:
1344
seq = sequences.pop()
1345
mem.write({'return_from': seq[0], 'return_to': seq[1]}, context=c)
1347
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1349
for obj in self.browse(cr, uid, ids, context=c):
1350
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1351
if mem.from_pack == 2:
1352
assert mem.integrity_status in rules, 'integrity status is wrong - %s - %s'%(rules, mem.integrity_status)
1354
I check rules from "integrity_check_return_packs_from_shipment"
1355
#2: (sfrom >= from) and (sto <= to) // in the initial range
1356
# present configuration of packs
1358
# so_a ppl_1 2,3 (split)
1361
!python {model: shipment.wizard}: |
1362
rules = ['seq_out_of_range','empty']
1363
sequences = [(2,2),(5,6)]
1364
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1365
ids = context['wizard']['ids']
1366
c = context['wizard']['c']
1368
self.deselect_all(cr, uid, ids, context=c)
1369
for obj in self.browse(cr, uid, ids, context=c):
1370
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1371
if mem.from_pack == 2:
1372
seq = sequences.pop()
1373
mem.write({'return_from': seq[0], 'return_to': seq[1]}, context=c)
1375
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1377
for obj in self.browse(cr, uid, ids, context=c):
1378
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1379
if mem.from_pack == 2:
1380
assert mem.integrity_status in rules, 'integrity status is wrong - %s - %s'%(rules, mem.integrity_status)
1382
I check rules from "integrity_check_return_packs_from_shipment"
1383
#2: (sfrom >= from) and (sto <= to) // in the initial range
1384
# present configuration of packs
1386
# so_a ppl_1 2,3 (split)
1389
!python {model: shipment.wizard}: |
1390
rules = ['seq_out_of_range','seq_out_of_range']
1391
sequences = [(1,2),(3,4)]
1392
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1393
ids = context['wizard']['ids']
1394
c = context['wizard']['c']
1396
self.deselect_all(cr, uid, ids, context=c)
1397
for obj in self.browse(cr, uid, ids, context=c):
1398
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1399
if mem.from_pack == 2:
1400
seq = sequences.pop()
1401
mem.write({'return_from': seq[0], 'return_to': seq[1]}, context=c)
1403
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1405
for obj in self.browse(cr, uid, ids, context=c):
1406
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1407
if mem.from_pack == 2:
1408
assert mem.integrity_status in rules, 'integrity status is wrong - %s - %s'%(rules, mem.integrity_status)
1410
I check rules from "integrity_check_return_packs_from_shipment"
1411
#2: (sfrom >= from) and (sto <= to) // in the initial range
1412
# present configuration of packs
1414
# so_a ppl_1 2,3 (split)
1417
!python {model: shipment.wizard}: |
1418
rules = ['seq_out_of_range','seq_out_of_range']
1419
sequences = [(0,1),(5,6)]
1420
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1421
ids = context['wizard']['ids']
1422
c = context['wizard']['c']
1424
self.deselect_all(cr, uid, ids, context=c)
1425
for obj in self.browse(cr, uid, ids, context=c):
1426
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1427
if mem.from_pack == 2:
1428
seq = sequences.pop()
1429
mem.write({'return_from': seq[0], 'return_to': seq[1]}, context=c)
1431
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1433
for obj in self.browse(cr, uid, ids, context=c):
1434
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1435
if mem.from_pack == 2:
1436
assert mem.integrity_status in rules, 'integrity status is wrong - %s - %s'%(rules, mem.integrity_status)
1438
I check rules from "integrity_check_return_packs_from_shipment"
1439
#2: (sfrom >= from) and (sto <= to) // in the initial range
1440
# present configuration of packs
1442
# so_a ppl_1 2,3 (split)
1445
!python {model: shipment.wizard}: |
1446
rules = ['overlap','empty']
1447
sequences = [(2,2),(2,3)]
1448
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1449
ids = context['wizard']['ids']
1450
c = context['wizard']['c']
1452
self.deselect_all(cr, uid, ids, context=c)
1453
for obj in self.browse(cr, uid, ids, context=c):
1454
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1455
if mem.from_pack == 2:
1456
seq = sequences.pop()
1457
mem.write({'return_from': seq[0], 'return_to': seq[1]}, context=c)
1459
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1461
for obj in self.browse(cr, uid, ids, context=c):
1462
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1463
if mem.from_pack == 2:
1464
assert mem.integrity_status in rules, 'integrity status is wrong - %s - %s'%(rules, mem.integrity_status)
1466
I check rules from "integrity_check_return_packs_from_shipment"
1467
#2: (sfrom >= from) and (sto <= to) // in the initial range
1468
# present configuration of packs
1470
# so_a ppl_1 2,3 (split)
1473
!python {model: shipment.wizard}: |
1474
rules = ['overlap','empty']
1475
sequences = [(2,3),(2,2)]
1476
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1477
ids = context['wizard']['ids']
1478
c = context['wizard']['c']
1480
self.deselect_all(cr, uid, ids, context=c)
1481
for obj in self.browse(cr, uid, ids, context=c):
1482
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1483
if mem.from_pack == 2:
1484
seq = sequences.pop()
1485
mem.write({'return_from': seq[0], 'return_to': seq[1]}, context=c)
1487
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1489
for obj in self.browse(cr, uid, ids, context=c):
1490
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1491
if mem.from_pack == 2:
1492
assert mem.integrity_status in rules, 'integrity status is wrong - %s - %s'%(rules, mem.integrity_status)
1494
I check rules from "integrity_check_return_packs_from_shipment"
1495
#2: (sfrom >= from) and (sto <= to) // in the initial range
1496
# present configuration of packs
1498
# so_a ppl_1 2,3 (split)
1501
!python {model: shipment.wizard}: |
1502
rules = ['overlap','empty']
1503
sequences = [(2,3),(3,3)]
1504
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1505
ids = context['wizard']['ids']
1506
c = context['wizard']['c']
1508
self.deselect_all(cr, uid, ids, context=c)
1509
for obj in self.browse(cr, uid, ids, context=c):
1510
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1511
if mem.from_pack == 2:
1512
seq = sequences.pop()
1513
mem.write({'return_from': seq[0], 'return_to': seq[1]}, context=c)
1515
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1517
for obj in self.browse(cr, uid, ids, context=c):
1518
for mem in obj.product_moves_shipment_returnpacksfromshipment:
1519
if mem.from_pack == 2:
1520
assert mem.integrity_status in rules, 'integrity status is wrong - %s - %s'%(rules, mem.integrity_status)
1522
I open the return from shipment wizard for shipment2
1524
!python {model: shipment}: |
1525
ids = context['shipment2']
1526
res = self.return_packs_from_shipment(cr, uid, ids, context=context)
1527
model = res['res_model']
1530
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
1534
!python {model: shipment.wizard}: |
1535
# return from shipment -> product_moves_shipment_returnpacksfromshipment ('stock.move.memory.shipment.returnpacksfromshipment')
1536
ids = context['wizard']['ids']
1537
c = context['wizard']['c']
1539
self.select_all(cr, uid, ids, context=c)
1541
self.do_return_packs_from_shipment(cr, uid, ids, context=c)
1543
I open the create shipment wizard
1545
!python {model: shipment}: |
1546
ids = context['draft_shipment']
1547
res = self.create_shipment(cr, uid, ids, context=context)
1548
model = res['res_model']
1551
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
1553
I recreate a second shipment with the rest
1554
# present configuration of packs
1558
!python {model: shipment.wizard}: |
1559
# create shipment -> product_moves_shipment_create ('stock.move.memory.shipment.create')
1560
ids = context['wizard']['ids']
1561
c = context['wizard']['c']
1563
self.select_all(cr, uid, ids, context=c)
1565
c.update({'yml_test': True})
1566
self.do_create_shipment(cr, uid, ids, context=c)
1567
# assert a shipment has been created
1568
shipment_ids = self.pool.get('shipment').search(cr, uid, [('parent_id', 'in', context['draft_shipment'])], context=context)
1569
assert len(shipment_ids) == 3, 'shipment should have been created - 3 - %s'%(len(shipment_ids))
1571
context.update({'shipment2': [max(shipment_ids)]})
1573
I validate the first shipment1
1575
!python {model: shipment}: |
1576
ids = context['shipment1']
1577
self.validate(cr, uid, ids, context=context)
1578
for ship in self.browse(cr,uid,ids):
1579
assert ship.state != 'draft', 'Shipment not validated :: Result : %s'%ship.state
1582
I check the state of both OUT objects. A should be draft, B should be done (everything has been shipped).
1584
!python {model: stock.picking}: |
1585
idsA = context['out']['a']
1586
idsB = context['out']['b']
1587
a_data = self.read(cr, uid, idsA, ['state'], context=context)
1588
assert a_data[0]['state'] == 'draft', 'the state of draft outgoing A is wrong - draft - %s'%a_data[0]['state']
1589
b_data = self.read(cr, uid, idsB, ['state'], context=context)
1590
assert b_data[0]['state'] == 'done', 'the state of draft outgoing B is wrong - done - %s'%b_data[0]['state']
1592
I check the draft shipment state, should still be draft. Shipment2 is still running.
1594
!python {model: shipment}: |
1595
data = self.read(cr, uid, context['draft_shipment'], ['state'], context=context)
1596
assert data[0]['state'] == 'draft', 'the shipment is not in the good state anymore - draft - %s'%data[0]['state']
1598
I validate the shipment2
1600
!python {model: shipment}: |
1601
ids = context['shipment2']
1602
self.validate(cr, uid, ids, context=context)
1604
I check the state of OUT object. A should still be draft.
1609
!python {model: stock.picking}: |
1610
quantities = [95,180,284]
1611
idsA = context['out']['a']
1612
a_data = self.read(cr, uid, idsA, ['state'], context=context)
1613
for obj in self.browse(cr, uid, idsA, context=context):
1614
for m in obj.move_lines:
1615
quantities.remove(m.product_qty)
1616
assert a_data[0]['state'] == 'draft', 'the state of draft outgoing A is wrong - draft - %s'%a_data[0]['state']
1617
assert not quantities, 'quantities from OUT A are wrong - [] - %s'%quantities
1619
I check the draft shipment state, should be done. Shipment2 is over. Some products stays \
1620
in the corresponding out, but the shipment is for now over.
1622
!python {model: shipment}: |
1623
data = self.read(cr, uid, context['draft_shipment'], ['state'], context=context)
1624
assert data[0]['state'] == 'done', 'the shipment is not in the good state anymore - done - %s'%data[0]['state']
1626
I bring products from SO A in quick mode into a new shipment. I open the create picking wizard for A
1628
!python {model: stock.picking}: |
1629
idsA = context['out']['a']
1630
self.force_assign(cr, uid, idsA)
1631
res = self.create_picking(cr, uid, idsA, context=context)
1632
model = res['res_model']
1635
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
1637
I create a partial picking ticket containing all products and production lots
1639
!python {model: create.picking}: |
1640
# create picking wizard -> product_moves_picking ('stock.move.memory.picking')
1641
ids = context['wizard']['ids']
1642
c = context['wizard']['c']
1644
self.select_all(cr, uid, ids, context=c)
1645
# set the production lots
1646
for obj in self.browse(cr, uid, ids, context=c):
1647
for mem in obj.product_moves_picking:
1648
if mem.product_id.id == context['product']['a']:
1649
mem.write({'prodlot_id': context['lot']['a']['s']}, context=c)
1650
if mem.product_id.id == context['product']['b']:
1651
mem.write({'prodlot_id': context['lot']['b']['i']}, context=c)
1652
if mem.product_id.id == context['product']['c']:
1653
mem.write({'prodlot_id': False}, context=c)
1654
# validate the creation
1655
self.do_create_picking(cr, uid, ids, context=c)
1656
# there should be one picking ticket created
1657
picking_ids = self.pool.get('stock.picking').search(cr, uid, [('backorder_id', 'in', context['out']['a'])], context=context)
1658
# add the picking ticket id to the context structure
1659
context.update({'pick': {'a': picking_ids}})
1660
assert len(picking_ids) == 2, 'picking ticket should have been created - 2 - %s'%(len(picking_ids))
1664
!python {model: stock.picking}: |
1665
ids = context['pick']['a']
1666
self.write(cr, uid, ids, {'flow_type': 'quick',}, context=context)
1668
I open the validate picking wizard for A
1670
!python {model: stock.picking}: |
1671
ids = context['pick']['a']
1672
res = self.validate_picking(cr, uid, ids, context=context)
1673
model = res['res_model']
1676
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
1678
I validate the picking
1680
!python {model: create.picking}: |
1681
# create picking wizard -> product_moves_picking ('stock.move.memory.picking')
1682
ids = context['wizard']['ids']
1683
c = context['wizard']['c']
1685
self.deselect_all(cr, uid, ids, context=c)
1686
self.select_all(cr, uid, ids, context=c)
1687
# validate the creation
1688
self.copy_all(cr, uid, ids, context=c)
1689
self.do_validate_picking(cr, uid, ids, context=c)
1690
# there should be one ppl created
1691
ppl_ids = self.pool.get('stock.picking').search(cr, uid, [('previous_step_id', 'in', context['pick']['a'])], context=context)
1692
# add the ppl id to the context structure
1693
context.update({'ppl': {'a': ppl_ids}})
1694
assert len(ppl_ids) == 3, 'ppl should have been created - 3 - %s'%(len(ppl_ids))
1696
I check a draft shipment has been created
1698
!python {model: shipment}: |
1699
ids = self.search(cr, uid, [('address_id', '=', context['address']), ('state', '=', 'draft')], context=context)
1700
assert len(ids) == 1, 'number of created shipment is wrong, 1 - %s'%len(ids)
1701
# set in the context
1702
context.update({'draft_shipment': ids})
1704
I open the create shipment wizard
1706
!python {model: shipment}: |
1707
ids = context['draft_shipment']
1708
res = self.create_shipment(cr, uid, ids, context=context)
1709
model = res['res_model']
1712
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
1714
I create shipment3 with the rest
1716
!python {model: shipment.wizard}: |
1717
# create shipment -> product_moves_shipment_create ('stock.move.memory.shipment.create')
1718
ids = context['wizard']['ids']
1719
c = context['wizard']['c']
1721
self.select_all(cr, uid, ids, context=c)
1723
c.update({'yml_test': True})
1724
self.do_create_shipment(cr, uid, ids, context=c)
1725
# assert a shipment has been created
1726
shipment_ids = self.pool.get('shipment').search(cr, uid, [('parent_id', 'in', context['draft_shipment'])], context=context)
1727
assert len(shipment_ids) == 1, 'shipment should have been created - 1 - %s'%(len(shipment_ids))
1729
context.update({'shipment3': [max(shipment_ids)]})
1731
I validate the shipment3
1733
!python {model: shipment}: |
1734
ids = context['shipment3']
1735
self.validate(cr, uid, ids, context=context)
1737
I check the state of OUT object. A should be done.
1739
!python {model: stock.picking}: |
1740
idsA = context['out']['a']
1741
a_data = self.read(cr, uid, idsA, ['state'], context=context)
1742
assert a_data[0]['state'] == 'done', 'the state of draft outgoing A is wrong - done - %s'%a_data[0]['state']
1744
I check the draft shipment state, should be done. Shipment3 is over.
1746
!python {model: shipment}: |
1747
data = self.read(cr, uid, context['draft_shipment'], ['state'], context=context)
1748
assert data[0]['state'] == 'done', 'the shipment is not in the good state anymore - done - %s'%data[0]['state']
110
wf_service.trg_validate(uid, 'sale.order', ref("sale_order_so0"), 'order_confirm', cr)
114
I check the draft picking creation and create picking object
117
!python {model: stock.picking}: |
118
ids = self.search(cr, uid, [('sale_id', '=', ref("sale_order_so0")), ('state', '=', 'draft')], context=context)
119
assert len(ids) == 1, 'number of created draft picking is wrong, 1 - %s'%len(ids)
120
res = self.create_picking(cr, uid, ids, context=context)
121
model = res['res_model']
124
self.pool.get(model).do_create_picking(cr, uid, [id], context=res['context'])
128
I check the picking creation, change the flow_type to 'quick' and validate it
131
!python {model: stock.picking}: |
132
ids = self.search(cr, uid, [('sale_id', '=', ref("sale_order_so0")), ('state', '=', 'assigned')], context=context)
133
assert len(ids) == 1, 'number of created draft picking is wrong, 1 - %s'%len(ids)
135
self.write(cr, uid, ids, {'flow_type': 'quick',}, context=context)
136
res = self.validate_picking(cr, uid, ids, context=context)
137
model = res['res_model']
140
self.pool.get(model).do_validate_picking(cr, uid, [id], context=res['context'])
144
I check the ppl creation, shipment draft and create a new shipment, ship it, validate it, and check
145
that draft shipment is done
148
!python {model: shipment}: |
149
ids = self.search(cr, uid, [('state', '=', 'draft'), ('address_id', '=', ref("res_partner_address_0"))], context=context)
150
assert len(ids) == 1, 'number of created draft shipment is wrong, 1 - %s'%len(ids)
152
# create a new shipment
153
res = self.create_shipment(cr, uid, ids, context=context)
154
model = res['res_model']
157
self.pool.get(model).do_create_shipment(cr, uid, [id], context=res['context'])
159
ids = self.search(cr, uid, [('state', '=', 'packed'), ('address_id', '=', ref("res_partner_address_0"))], context=context)
160
assert len(ids) == 1, 'number of created shipment is wrong, 1 - %s'%len(ids)
161
self.ship(cr, uid, ids, context=context)
163
self.validate(cr, uid, ids, context=context)
165
assert self.browse(cr, uid, ids[0], context=context).state == 'done', 'state is wrong for validated shipment - done - %s'%self.browse(cr, uid, ids[0], context=context).state
166
assert self.browse(cr, uid, ids[0], context=context).backshipment_id.state == 'done', 'state is wrong for draft shipment - done - %s'%self.browse(cr, uid, ids[0], context=context).backshipment_id.state
170
I check the ppl creation, shipment draft and create a new shipment, ship it, validate it, and check
171
that draft shipment is done
174
!python {model: stock.picking}: |
175
ids = self.search(cr, uid, [('sale_id', '=', ref("sale_order_so0")),], context=context)
176
# we must have 6 objects - draft picking - picking - ppl - draft packing - packing (packed) - packing (shipped)
177
objects = ['draft_picking', 'picking', 'ppl', 'draft_packing', 'packing_packed', 'packing_shipped']
178
assert len(ids) == len(objects), 'the number of picking objects is wrong - %s - %s'%(len(objects), len(ids))
179
assert all([p.state == 'done' for p in self.browse(cr, uid, ids, context=context)]), 'all corresponding picking objects are not done - %s'%[p.state == 'done' for p in self.browse(cr, uid, ids, context=context)]