~unifield-team/unifield-wm/us-671-homere

« back to all changes in this revision

Viewing changes to threshold_value/test/threshold.yml

[UF-43] fix added noupdate to demo data

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
-
2
 
  In order to test the threshold rules feature, I will create
3
 
  a threshold rule for each product defined in data.yml, run
4
 
  the scheduler and check if a procurement order is created or
5
 
  not
6
 
-
7
 
  I create a threshold rule for product1/2/5/8/9/11
8
 
-
9
 
  !record {model: threshold.value, id: threshold1}:
10
 
    name: Threshold1
11
 
    location_id: stock.stock_location_stock
12
 
    compute_method: computed
13
 
    consumption_method: amc
14
 
    frequency: 3.00
15
 
    safety_month: 1.00
16
 
    lead_time: 1.50
17
 
    supplier_lt: False
18
 
    line_ids:
19
 
      - product_id: product1
20
 
        product_uom_id: product.product_uom_unit
21
 
      - product_id: product2
22
 
        product_uom_id: product.product_uom_unit
23
 
      - product_id: product5
24
 
        product_uom_id: product.product_uom_unit
25
 
      - product_id: product8
26
 
        product_uom_id: product.product_uom_unit
27
 
      - product_id: product9
28
 
        product_uom_id: product.product_uom_unit
29
 
      - product_id: product11
30
 
        product_uom_id: product.product_uom_unit
31
 
-
32
 
  Update the period of consumption
33
 
-
34
 
  !python {model: threshold.value}: |
35
 
    import datetime
36
 
    from dateutil.relativedelta import relativedelta
37
 
    self.write(cr, uid, [ref('threshold1')], {'consumption_period_from': (datetime.datetime.today() + relativedelta(day=1, months=-2)).strftime('%Y-%m-%d'), 
38
 
                                              'consumption_period_to': (datetime.datetime.today() + relativedelta(months=1, day=1, days=-1)).strftime('%Y-%m-%d')})
39
 
-
40
 
  I create a threshold rule for product3/4/6/7
41
 
-
42
 
  !record {model: threshold.value, id: threshold2}:
43
 
    name: Threshold2
44
 
    location_id: stock.stock_location_stock
45
 
    compute_method: fixed
46
 
    line_ids:
47
 
      - product_id: product3
48
 
        product_uom_id: product.product_uom_unit
49
 
        fixed_threshold_value: 250
50
 
        fixed_product_qty: 500
51
 
      - product_id: product4
52
 
        product_uom_id: product.product_uom_unit
53
 
        fixed_threshold_value: 250
54
 
        fixed_product_qty: 75
55
 
      - product_id: product6
56
 
        product_uom_id: product.product_uom_unit
57
 
        fixed_threshold_value: 250
58
 
        fixed_product_qty: 150
59
 
      - product_id: product7
60
 
        product_uom_id: product.product_uom_unit
61
 
        fixed_threshold_value: 250
62
 
        fixed_product_qty: 150
63
 
-
64
 
  I run the scheduler
65
 
-
66
 
  !python {model: procurement.order}: |
67
 
    self.run_threshold_value(cr, uid, False, context={})
68
 
69
 
  I check if a procurement order was created
70
 
-
71
 
  !python {model: procurement.order}: |
72
 
    res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold1'), ('product_id', '=', ref('product1'))], context=context)
73
 
    assert res_ids, "No procurement created for product 1"
74
 
    res = self.browse(cr, uid, res_ids[0], context=context)
75
 
    assert res.product_qty == 175.00, "Bad quantity on procurement order for Product 1 (Expected 175.00 :: %s)" % res.product_qty
76
 
77
 
  I check if a procurement order was created
78
 
-
79
 
  !python {model: procurement.order}: |
80
 
    res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold1'), ('product_id', '=', ref('product2'))], context=context)
81
 
    assert not res_ids, "Procurement created for product 2"
82
 
83
 
  I check if a procurement order was created
84
 
-
85
 
  !python {model: procurement.order}: |
86
 
    res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold2'), ('product_id', '=', ref('product3'))], context=context)
87
 
    assert not res_ids, "Procurement created for product 3"
88
 
89
 
  I check if a procurement order was created
90
 
-
91
 
  !python {model: procurement.order}: |
92
 
    res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold2'), ('product_id', '=', ref('product4'))], context=context)
93
 
    assert res_ids, "No procurement created for product 4"
94
 
    res = self.browse(cr, uid, res_ids[0], context=context)
95
 
    assert res.product_qty == 75.00, "Bad quantity on procurement order for Product 4 (Expected 75.00 :: %s)" % res.product_qty
96
 
97
 
  I check if a procurement order was created
98
 
-
99
 
  !python {model: procurement.order}: |
100
 
    res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold1'), ('product_id', '=', ref('product5'))], context=context)
101
 
    assert res_ids, "No procurement created for product 5"
102
 
    res = self.browse(cr, uid, res_ids[0], context=context)
103
 
    assert res.product_qty == 175.00, "Bad quantity on procurement order for Product 5 (Expected 175.00 :: %s)" % res.product_qty
104
 
105
 
  I check if a procurement order was created
106
 
-
107
 
  !python {model: procurement.order}: |
108
 
    res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold2'), ('product_id', '=', ref('product6'))], context=context)
109
 
    assert res_ids, "No procurement created for product 6"
110
 
    res = self.browse(cr, uid, res_ids[0], context=context)
111
 
    assert res.product_qty == 150.00, "Bad quantity on procurement order for Product 6 (Expected 150.00 :: %s)" % res.product_qty
112
 
113
 
  I check if a procurement order was created
114
 
-
115
 
  !python {model: procurement.order}: |
116
 
    res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold2'), ('product_id', '=', ref('product7'))], context=context)
117
 
    assert not res_ids, "Procurement created for product 7"
118
 
119
 
  I check if a procurement order was created
120
 
-
121
 
  !python {model: procurement.order}: |
122
 
    res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold1'), ('product_id', '=', ref('product8'))], context=context)
123
 
    assert res_ids, "No procurement created for product 8"
124
 
    res = self.browse(cr, uid, res_ids[0], context=context)
125
 
    assert res.product_qty == 175.00, "Bad quantity on procurement order for Product 8 (Expected 175.00 :: %s)" % res.product_qty
126
 
127
 
  I check if a procurement order was created
128
 
-
129
 
  !python {model: procurement.order}: |
130
 
    res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold1'), ('product_id', '=', ref('product9'))], context=context)
131
 
    assert len(res_ids) == 1, "Too procurement created for threshold 9"
132
 
    res = self.browse(cr, uid, res_ids[0], context=context)
133
 
    assert res.product_id.id == ref('product9'), "No procurement created for product 9"
134
 
    assert res.product_qty == 175.00, "Bad quantity on procurement order for Product 9 (Expected 175.00 :: %s)" % res.product_qty
135
 
136
 
  I check if a procurement order was created
137
 
-
138
 
  !python {model: procurement.order}: |
139
 
    res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold1'), ('product_id', '=', ref('product11'))], context=context)
140
 
    assert len(res_ids) == 1, "Too procurement created for threshold 11"
141
 
    res = self.browse(cr, uid, res_ids[0], context=context)
142
 
    assert res.product_id.id == ref('product11'), "Bad product on procurement order for Threshold 11"
143
 
    assert res.product_qty == 175.00, "Bad quantity on procurement order for Product 11 (Expected 175.00 :: %s)" % res.product_qty
 
 
b'\\ No newline at end of file'