2
In order to test the product likely to expire report, I will create
3
new reports and see if values are good
5
!record {model: product.likely.expire.report, id: pler1}:
6
date_from: '2011-11-14'
10
I launch the calculation
12
!python {model: product.likely.expire.report}: |
13
self.process_lines(cr, uid, ref('pler1'), context=context)
15
Check if all lines are created
17
!python {model: product.likely.expire.report}: |
18
report = self.browse(cr, uid, ref('pler1'), context=context)
19
assert len(report.line_ids) >= 3, "All lines aren't created by the expiry calculation process"
21
for line in report.line_ids:
22
if line.product_id.id == ref('product5'):
24
if line.product_id.id == ref('product6'):
26
if line.product_id.id == ref('product7'):
28
assert p5, "No line created for P5"
29
assert p6, "No line created for P6"
30
assert p7, "No line created for P7"
32
Check if the first line has good values
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 == 114.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 == 53.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, )