2
In order to test dates in Orders, I create initial data
8
!record {model: res.partner, id: cust1}:
12
I create an address for C1
14
!record {model: res.partner.address, id: addrc1}:
20
!record {model: res.partner, id: supplier1}:
25
I create the address for S1
27
!record {model: res.partner.address, id: address1}:
31
I create the supplier S2
33
!record {model: res.partner, id: supplier2}:
38
I create the address for S2
40
!record {model: res.partner.address, id: address2}:
44
I create the supplier S3
46
!record {model: res.partner, id: supplier3}:
50
I create the address for S3
52
!record {model: res.partner.address, id: address3}:
56
In order to test the procurement list module, I start by creating a new product category
58
!record {model: product.category, id: product_cat1}:
63
!record {model: product.category, id: product_cat2}:
66
I create the product P1
68
!record {model: product.product, id: product1}:
69
categ_id: product_cat1
74
procure_method: make_to_stock
75
property_stock_inventory: stock.location_inventory
76
property_stock_procurement: stock.location_procurement
77
property_stock_production: stock.location_production
82
uom_id: product.product_uom_unit
83
uom_po_id: product.product_uom_unit
88
reviewed_consumption: 45
96
international_status: product_attributes.int_1
98
I create a second product, P2
100
!record {model: product.product, id: product2}:
101
categ_id: product_cat1
102
cost_method: standard
106
procure_method: make_to_stock
107
property_stock_inventory: stock.location_inventory
108
property_stock_procurement: stock.location_procurement
109
property_stock_production: stock.location_production
111
standard_price: 100.0
114
uom_id: product.product_uom_unit
115
uom_po_id: product.product_uom_unit
120
reviewed_consumption: 50
128
international_status: product_attributes.int_1
130
I create the product P3
132
!record {model: product.product, id: product3}:
133
categ_id: product_cat1
134
cost_method: standard
138
procure_method: make_to_stock
139
property_stock_inventory: stock.location_inventory
140
property_stock_procurement: stock.location_procurement
141
property_stock_production: stock.location_production
143
standard_price: 100.0
146
uom_id: product.product_uom_unit
147
uom_po_id: product.product_uom_unit
152
reviewed_consumption: 30
153
batch_management: True
159
international_status: product_attributes.int_1
161
I create the product P4
163
!record {model: product.product, id: product4}:
164
categ_id: product_cat2
165
cost_method: standard
169
procure_method: make_to_stock
170
property_stock_inventory: stock.location_inventory
171
property_stock_procurement: stock.location_procurement
172
property_stock_production: stock.location_production
174
standard_price: 100.0
177
uom_id: product.product_uom_unit
178
uom_po_id: product.product_uom_unit
183
reviewed_consumption: 15
189
international_status: product_attributes.int_1
191
In order to check the real stock, I will create four SLoc with Sloc3 and Sloc4 which are children of Sloc2
195
!record {model: stock.location, id: cycle_sloc1}:
201
!record {model: stock.location, id: cycle_sloc2}:
207
!record {model: stock.location, id: cycle_sloc3}:
210
location_id: cycle_sloc2
214
!record {model: stock.location, id: cycle_sloc4}:
217
location_id: cycle_sloc2
219
I create a new Warehouse
221
!record {model: stock.warehouse, id: warehouse_proc_cycle}:
222
name: Warehouse Cycle
223
lot_stock_id: cycle_sloc2
224
lot_input_id: cycle_sloc2
225
lot_dispatch_id: cycle_sloc2
226
lot_output_id: stock.stock_location_customers
227
company_id: base.main_company
231
!record {model: sale.shop, id: shop_cycle}:
232
payment_default_id: account.account_payment_term
234
warehouse_id: warehouse_proc_cycle
236
I create a batch for product 3 with today + 2 months as expiry date
238
!record {model: stock.production.lot, id: lot1}:
243
I add the life date on the lot
245
!python {model: stock.production.lot }: |
247
from datetime import datetime
248
from dateutil.relativedelta import relativedelta
249
req_date = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(months=2)).strftime('%Y-%m-%d')
250
self.write(cr, uid, ref('lot1'), {'life_date': req_date}, context=context)
252
I create a batch for product 3 with today + 1 month as expiry date
254
!record {model: stock.production.lot, id: lot2}:
259
I add the life date on the lot
261
!python {model: stock.production.lot }: |
263
from datetime import datetime
264
from dateutil.relativedelta import relativedelta
265
req_date = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(months=1)).strftime('%Y-%m-%d')
266
self.write(cr, uid, ref('lot2'), {'life_date': req_date}, context=context)
268
I create a batch for product 3 with today + 15 days as expiry date
270
!record {model: stock.production.lot, id: lot3}:
275
I add the life date on the lot
277
!python {model: stock.production.lot }: |
279
from datetime import datetime
280
from dateutil.relativedelta import relativedelta
281
req_date = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=15)).strftime('%Y-%m-%d')
282
self.write(cr, uid, ref('lot3'), {'life_date': req_date}, context=context)
284
I create a batch for product 3 with today + 6 months as expiry date
286
!record {model: stock.production.lot, id: lot4}:
291
I add the life date on the lot
293
!python {model: stock.production.lot }: |
295
from datetime import datetime
296
from dateutil.relativedelta import relativedelta
297
req_date = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(months=6)).strftime('%Y-%m-%d')
298
self.write(cr, uid, ref('lot4'), {'life_date': req_date}, context=context)
300
I create a batch for product 3 with today + 2 years as expiry date
302
!record {model: stock.production.lot, id: lot5}:
307
I add the life date on the lot
309
!python {model: stock.production.lot }: |
311
from datetime import datetime
312
from dateutil.relativedelta import relativedelta
313
req_date = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(years=2)).strftime('%Y-%m-%d')
314
self.write(cr, uid, ref('lot5'), {'life_date': req_date}, context=context)
316
!record {model: stock.production.lot, id: lot22}:
320
life_date: !eval "(DateTime.now()+DateTime.RelativeDateTime(months=1)).strftime('%Y-%m-%d')"
323
I create an inventory to add products in stock
325
!record {model: stock.inventory, id: inv1}:
327
company_id: base.main_company
328
date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
329
date_done: !eval time.strftime('%Y-%m-%d %H:%M:%S')
331
- company_id: base.main_company
332
location_id: cycle_sloc1
335
product_uom: product.product_uom_unit
336
- company_id: base.main_company
337
location_id: cycle_sloc2
340
product_uom: product.product_uom_unit
341
- company_id: base.main_company
342
location_id: cycle_sloc3
345
product_uom: product.product_uom_unit
346
- company_id: base.main_company
347
location_id: cycle_sloc1
350
product_uom: product.product_uom_unit
351
- company_id: base.main_company
352
location_id: cycle_sloc2
355
product_uom: product.product_uom_unit
356
- company_id: base.main_company
357
location_id: cycle_sloc1
361
product_uom: product.product_uom_unit
362
- company_id: base.main_company
363
location_id: cycle_sloc2
367
product_uom: product.product_uom_unit
368
- company_id: base.main_company
369
location_id: cycle_sloc2
373
product_uom: product.product_uom_unit
374
- company_id: base.main_company
375
location_id: cycle_sloc2
379
product_uom: product.product_uom_unit
380
- company_id: base.main_company
381
location_id: cycle_sloc2
385
product_uom: product.product_uom_unit
386
- company_id: base.main_company
387
location_id: cycle_sloc3
391
product_uom: product.product_uom_unit
392
- company_id: base.main_company
393
location_id: cycle_sloc4
397
product_uom: product.product_uom_unit
398
- company_id: base.main_company
399
location_id: cycle_sloc2
402
product_uom: product.product_uom_unit
405
I confirm the inventory
407
!python {model: stock.inventory}: |
408
self.action_confirm(cr,uid,[ref('inv1')])
409
self.action_done(cr,uid,[ref('inv1')])
411
I check if the availability of P1 is correct
413
!assert {model: product.product, id: product1}:
414
- qty_available == 47.0
415
- virtual_available == 47.0
417
I create a sale order with 15 P1
419
!record {model: sale.order, id: so1}:
422
date_order: !eval time.strftime('%Y-%m-%d')
423
invoice_quantity: order
425
- company_id: base.main_company
430
product_uom: product.product_uom_unit
431
product_uom_qty: 15.0
432
product_uos_qty: 15.0
437
partner_invoice_id: addrc1
438
partner_order_id: addrc1
439
partner_shipping_id: addrc1
440
picking_policy: direct
441
pricelist_id: product.list0
444
I confirm the Sale Order
446
!workflow {model: sale.order, action: order_confirm, ref: so1}
448
I check if the availability of P1 is correct
450
!assert {model: product.product, id: product1}:
451
- qty_available == 47.0
452
- virtual_available == 32.0
454
I check if the availability of P3 is correct
456
!assert {model: product.product, id: product3}:
457
- qty_available == 830.0
458
- virtual_available == 830.0
460
I create a Purchase Order with 35 P3
462
!record {model: purchase.order, id: po1}:
463
company_id: base.main_company
464
date_order: !eval time.strftime('%Y-%m-%d')
465
invoice_method: order
466
location_id: cycle_sloc3
468
- date_planned: !eval time.strftime('%Y-%m-%d')
473
product_uom: product.product_uom_unit
475
partner_address_id: address1
476
partner_id: supplier1
477
pricelist_id: purchase.list0
479
I validate this purchase order
481
!workflow {model: purchase.order, action: purchase_confirm, ref: po1}
483
I approve this purchase order
485
!workflow {model: purchase.order, action: purchase_approve, ref: po1}
487
I check if the availability of P3 is correct
489
!assert {model: product.product, id: product3}:
490
- qty_available == 830.0
491
- virtual_available == 865.0
493
I crete a new FMC report for SlocĀ 2
495
!record {model: monthly.review.consumption, id: mrc2}:
496
cons_location_id: cycle_sloc2
497
period_from: 2011-01-01
498
period_to: !eval time.strftime('%Y-%m-%d')
510
I create a stock move for P1 in SLoc 2
512
!record {model: stock.move, id: sm_p1_sloc2}:
513
name: Product 1 SLoc 2
515
product_uom: product.product_uom_unit
516
date_expected: !eval time.strftime('%Y-%m-%d')
517
date: !eval time.strftime('%Y-%m-%d')
518
location_id: cycle_sloc2
519
location_dest_id: stock.stock_location_customers
521
reason_type_id: reason_types_moves.reason_type_deliver_partner
524
I confirm the stock move
526
!python {model: stock.move}: |
527
self.action_confirm(cr, uid, ref('sm_p1_sloc2'), context=context)
528
self.action_done(cr, uid, ref('sm_p1_sloc2'), context=context)
530
I create a stock move for P1 in SLoc 1
532
!record {model: stock.move, id: sm_p1_sloc1}:
533
name: Product 1 SLoc 1
535
product_uom: product.product_uom_unit
536
date_expected: !eval time.strftime('%Y-%m-%d')
537
date: !eval time.strftime('%Y-%m-%d')
538
location_id: cycle_sloc1
539
location_dest_id: stock.stock_location_customers
541
reason_type_id: reason_types_moves.reason_type_deliver_partner
544
I confirm the stock move
546
!python {model: stock.move}: |
547
self.action_confirm(cr, uid, ref('sm_p1_sloc1'), context=context)
548
self.action_done(cr, uid, ref('sm_p1_sloc1'), context=context)
550
I create a stock move for P2 in SLoc 1
552
!record {model: stock.move, id: sm_p2_sloc1}:
553
name: Product 2 SLoc 1
555
product_uom: product.product_uom_unit
556
date_expected: !eval time.strftime('%Y-%m-%d')
557
date: !eval time.strftime('%Y-%m-%d')
558
location_id: cycle_sloc1
559
location_dest_id: stock.stock_location_customers
561
reason_type_id: reason_types_moves.reason_type_deliver_partner
564
I confirm the stock move
566
!python {model: stock.move}: |
567
self.action_confirm(cr, uid, ref('sm_p2_sloc1'), context=context)
568
self.action_done(cr, uid, ref('sm_p2_sloc1'), context=context)
570
I create a stock move for P2 in SLoc 2
572
!record {model: stock.move, id: sm_p2_sloc2}:
573
name: Product 2 SLoc 2
575
product_uom: product.product_uom_unit
576
date_expected: !eval time.strftime('%Y-%m-%d')
577
date: !eval time.strftime('%Y-%m-%d')
578
location_id: cycle_sloc2
579
location_dest_id: stock.stock_location_customers
581
reason_type_id: reason_types_moves.reason_type_deliver_partner
584
I confirm the stock move
586
!python {model: stock.move}: |
587
self.action_confirm(cr, uid, ref('sm_p2_sloc2'), context=context)
588
self.action_done(cr, uid, ref('sm_p2_sloc2'), context=context)
590
I create a stock move for P3 in SLoc 1
592
!record {model: stock.move, id: sm_p3_sloc1}:
593
name: Product 3 SLoc 1
595
product_uom: product.product_uom_unit
596
date_expected: !eval time.strftime('%Y-%m-%d')
597
date: !eval time.strftime('%Y-%m-%d')
598
location_id: cycle_sloc1
599
location_dest_id: stock.stock_location_customers
602
reason_type_id: reason_types_moves.reason_type_deliver_partner
605
I confirm the stock move
607
!python {model: stock.move}: |
608
self.action_confirm(cr, uid, ref('sm_p3_sloc1'), context=context)
609
self.action_done(cr, uid, ref('sm_p3_sloc1'), context=context)
611
I create a stock move for P2 in SLoc 1
613
!record {model: stock.move, id: sm_p4_sloc2}:
614
name: Product 4 SLoc 2
616
product_uom: product.product_uom_unit
617
date_expected: !eval time.strftime('%Y-%m-%d')
618
date: !eval time.strftime('%Y-%m-%d')
619
location_id: cycle_sloc2
620
location_dest_id: stock.stock_location_customers
622
reason_type_id: reason_types_moves.reason_type_deliver_partner
625
I confirm the stock move
627
!python {model: stock.move}: |
628
self.action_confirm(cr, uid, ref('sm_p4_sloc2'), context=context)
629
self.action_done(cr, uid, ref('sm_p4_sloc2'), context=context)