29
28
assert p6, "No line created for P6"
30
29
assert p7, "No line created for P7"
32
Check if the first line has good values
31
Check if the first line are good values
33
!python {model: product.likely.expire.report.line}: |
35
from datetime import datetime
36
from dateutil.relativedelta import relativedelta
37
p50days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=50)).strftime('%Y-%m-%d')
38
p12days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=12)).strftime('%Y-%m-%d')
39
p15days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=15)).strftime('%Y-%m-%d')
40
p25days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=25)).strftime('%Y-%m-%d')
41
p17days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=17)).strftime('%Y-%m-%d')
42
line_ids = self.search(cr, uid, [('product_id', '=', ref('product5')), ('report_id', '=', ref('exp1'))], context=context)
43
for line in self.browse(cr, uid, line_ids, context=context):
44
assert line.real_stock == 80.00, "Real stock is not correct for the product P5"
45
assert line.total_expired == 54.00, "Total expired is not correct for the product P5"
46
exp_line_ids = self.pool.get('expiry.report.date.line').search(cr, uid, [('line_id', '=', line.id)], context=context)
47
for exp_line in self.pool.get('expiry.report.date.line').browse(cr, uid, exp_line_ids, context=context):
48
if exp_line.name == p12days:
49
assert exp_line.qty == 45.00, "Quantity for P5 at today + 12 days is not correct"
50
assert exp_line.expired_qty == 19.00, "Expiry quantities for P5 at today + 12 days is not correct"
51
if exp_line.name == p15days:
52
assert exp_line.qty == 43.00, "Quantity for P5 at today + 15 days is not correct"
53
assert exp_line.expired_qty == 00.00, "Expiry quantities for P5 at today + 15 days is not correct"
54
if exp_line.name == p17days:
55
assert exp_line.qty == 42.00, "Quantity for P5 at today + 17 days is not correct"
56
assert exp_line.expired_qty == 0.00, "Expiry quantities for P5 at today + 17 days is not correct"
57
if exp_line.name == p25days:
58
assert exp_line.qty == 39.00, "Quantity for P5 at today + 25 days is not correct"
59
assert exp_line.expired_qty == 0.00, "Expiry quantities for P5 at today + 25 days is not correct"
60
if exp_line.name == p50days:
61
assert exp_line.qty == 0.00, "Quantity for P5 at today + 50 days is not correct"
62
assert exp_line.expired_qty == 25.00, "Expiry quantities for P5 at today + 50 days is not correct"
64
Check if the second line are good values
66
!python {model: product.likely.expire.report.line}: |
68
from datetime import datetime
69
from dateutil.relativedelta import relativedelta
70
p50days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=50)).strftime('%Y-%m-%d')
71
p12days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=12)).strftime('%Y-%m-%d')
72
p15days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=15)).strftime('%Y-%m-%d')
73
p25days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=25)).strftime('%Y-%m-%d')
74
p17days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=17)).strftime('%Y-%m-%d')
75
line_ids = self.search(cr, uid, [('product_id', '=', ref('product6')), ('report_id', '=', ref('exp1'))], context=context)
76
for line in self.browse(cr, uid, line_ids, context=context):
77
assert line.real_stock == 38.00, "Real stock is not correct for the product P6"
78
assert line.total_expired == 21.00, "Total expired is not correct for the product P6"
79
exp_line_ids = self.pool.get('expiry.report.date.line').search(cr, uid, [('line_id', '=', line.id)], context=context)
80
for exp_line in self.pool.get('expiry.report.date.line').browse(cr, uid, exp_line_ids, context=context):
81
if exp_line.name == p12days:
82
assert exp_line.qty == 34.00, "Quantity for P6 at today + 12 days is not correct"
83
assert exp_line.expired_qty == 0.00, "Expiry uantities for P6 at today + 12 days is not correct"
84
if exp_line.name == p15days:
85
assert exp_line.qty == 13.00, "Quantity for P6 at today + 15 days is not correct"
86
assert exp_line.expired_qty == 20.00, "Expiry uantities for P6 at today + 15 days is not correct"
87
if exp_line.name == p17days:
88
assert exp_line.qty == 12.00, "Quantity for P6 at today + 17 days is not correct"
89
assert exp_line.expired_qty == 0.00, "Expiry uantities for P6 at today + 17 days is not correct"
90
if exp_line.name == p25days:
91
assert exp_line.qty == 10.00, "Quantity for P6 at today + 25 days is not correct"
92
assert exp_line.expired_qty == 0.00, "Expiry uantities for P6 at today + 25 days is not correct"
93
if exp_line.name == p50days:
94
assert exp_line.qty == 0.00, "Quantity for P6 at today + 50 days is not correct"
95
assert exp_line.expired_qty == 1.00, "Expiry uantities for P6 at today + 50 days is not correct"
97
Check if the third line are good values
99
!python {model: product.likely.expire.report.line}: |
101
from datetime import datetime
102
from dateutil.relativedelta import relativedelta
103
p50days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=50)).strftime('%Y-%m-%d')
104
p12days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=12)).strftime('%Y-%m-%d')
105
p15days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=15)).strftime('%Y-%m-%d')
106
p25days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=25)).strftime('%Y-%m-%d')
107
p17days = (datetime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') + relativedelta(days=17)).strftime('%Y-%m-%d')
108
line_ids = self.search(cr, uid, [('product_id', '=', ref('product7')), ('report_id', '=', ref('exp1'))], context=context)
109
for line in self.browse(cr, uid, line_ids, context=context):
110
assert line.real_stock == 108.00, "Real stock is not correct for the product P7"
111
assert line.total_expired == 78.00, "Total expired is not correct for the product P7"
112
exp_line_ids = self.pool.get('expiry.report.date.line').search(cr, uid, [('line_id', '=', line.id)], context=context)
113
for exp_line in self.pool.get('expiry.report.date.line').browse(cr, uid, exp_line_ids, context=context):
114
if exp_line.name == p12days:
115
assert exp_line.qty == 86.00, "Quantity for P7 at today + 12 days is not correct"
116
assert exp_line.expired_qty == 0.00, "Expiry quantities for P7 at today + 12 days is not correct"
117
if exp_line.name == p15days:
118
assert exp_line.qty == 83.00, "Quantity for P7 at today + 15 days is not correct"
119
assert exp_line.expired_qty == 0.00, "Expiry quantities for P7 at today + 15 days is not correct"
120
if exp_line.name == p17days:
121
assert exp_line.qty == 81.00, "Quantity for P7 at today + 17 days is not correct"
122
assert exp_line.expired_qty == 0.00, "Expiry quantities for P7 at today + 17 days is not correct"
123
if exp_line.name == p25days:
124
assert exp_line.qty == 10.00, "Quantity for P7 at today + 25 days is not correct"
125
assert exp_line.expired_qty == 66.00, "Expiry quantities for P7 at today + 25 days is not correct"
126
if exp_line.name == p50days:
127
assert exp_line.qty == -13.00, "Quantity for P7 at today + 50 days is not correct"
128
assert exp_line.expired_qty == 0.00, "Expiry quantities for P7 at today + 50 days is not correct"
130
!record {model: product.likely.expire.report, id: exp2}:
131
date_to: !eval "'2020-12-31'"
132
consumption_type: rac
134
I launch the calculation
34
!python {model: product.likely.expire.report.line}: |
37
from dateutil.relativedelta import relativedelta
38
line_ids = self.search(cr, uid, [('product_id', '=', ref('product5')), ('report_id', '=', ref('pler1'))], context=context)
39
for line in self.browse(cr, uid, line_ids, context=context):
40
assert line.in_stock == 600.00, "In stock is not correct for the product P5"
41
assert line.total_expired == 121.00, "Expired quantity is not correct for product P5 %s"%(line.total_expired,)
42
assert line.consumption == 200.00, "Consumption is not correct for product P5"
43
item_ids = self.pool.get('product.likely.expire.report.item').search(cr, uid, [('line_id', '=', line.id)])
45
item1 = self.pool.get('product.likely.expire.report.item').browse(cr, uid, item_ids[0])
46
assert item1.expired_qty == 60.00, "1, %s"%(item1.expired_qty, )
48
item2 = self.pool.get('product.likely.expire.report.item').browse(cr, uid, item_ids[1])
49
assert item2.expired_qty == 0.00, "2 , %s"%(item2.expired_qty, )
51
item3 = self.pool.get('product.likely.expire.report.item').browse(cr, uid, item_ids[2])
52
assert item3.expired_qty == 61.00, "3 , %s"%(item3.expired_qty, )
54
item4 = self.pool.get('product.likely.expire.report.item').browse(cr, uid, item_ids[3])
55
assert item4.expired_qty == 0.00, "4 , %s"%(item4.expired_qty, )
136
!python {model: product.likely.expire.report}: |
138
self.process_lines(cr, uid, ref('exp2'), context=context)
140
assert False, "Error on Real Average Consumption"
b'\\ No newline at end of file'