~unifield-team/unifield-wm/us-826

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
-
  In order to test the product likely to expire report, I will create
  new reports and see if values are good
-
  !record {model: product.likely.expire.report, id: pler1}:
    date_from: '2011-11-14'
    date_to: '2012-02-20'
    consumption_type: fmc
-
    I launch the calculation
- 
  !python {model: product.likely.expire.report}: |
    self.process_lines(cr, uid, ref('pler1'), context=context)
-
  Check if all lines are created
- 
  !python {model: product.likely.expire.report}: |
    report = self.browse(cr, uid, ref('pler1'), context=context)
    assert len(report.line_ids) >= 3, "All lines aren't created by the expiry calculation process"
    p5 = p6 = p7 = False
    for line in report.line_ids:
      if line.product_id.id == ref('product5'):
        p5 = True
      if line.product_id.id == ref('product6'):
        p6 = True
      if line.product_id.id == ref('product7'):
        p7 = True
    assert p5, "No line created for P5"
    assert p6, "No line created for P6"
    assert p7, "No line created for P7"
-
  Check if the first line has good values
- 
  !python {model: product.likely.expire.report.line}: |
    import time
    import datetime
    from dateutil.relativedelta import relativedelta
    line_ids = self.search(cr, uid, [('product_id', '=', ref('product5')), ('report_id', '=', ref('pler1'))], context=context)
    for line in self.browse(cr, uid, line_ids, context=context):
      assert line.in_stock == 600.00, "In stock is not correct for the product P5"
      assert line.total_expired == 114.00, "Expired quantity is not correct for product P5 %s"%(line.total_expired,)
      assert line.consumption == 200.00, "Consumption is not correct for product P5"
      item_ids = self.pool.get('product.likely.expire.report.item').search(cr, uid, [('line_id', '=', line.id)])
        
      item1 = self.pool.get('product.likely.expire.report.item').browse(cr, uid, item_ids[0])
      assert item1.expired_qty == 53.00, "1, %s"%(item1.expired_qty, )

      item2 = self.pool.get('product.likely.expire.report.item').browse(cr, uid, item_ids[1])
      assert item2.expired_qty == 0.00, "2 , %s"%(item2.expired_qty, )
        
      item3 = self.pool.get('product.likely.expire.report.item').browse(cr, uid, item_ids[2])
      assert item3.expired_qty == 61.00, "3 , %s"%(item3.expired_qty, )
        
      item4 = self.pool.get('product.likely.expire.report.item').browse(cr, uid, item_ids[3])
      assert item4.expired_qty == 0.00, "4 , %s"%(item4.expired_qty, )