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
7
I create a threshold rule for product1
9
!record {model: threshold.value, id: threshold1}:
12
uom_id: product.product_uom_unit
13
location_id: stock.stock_location_stock
15
threshold_manual_ok: False
17
qty_order_manual_ok: False
25
!python {model: procurement.order}: |
26
self.run_threshold_value(cr, uid, False, context={})
28
I check if a procurement order was created
30
!python {model: procurement.order}: |
31
res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold1')], context=context)
32
assert res_ids, "No procurement created for product 1"
33
res = self.browse(cr, uid, res_ids[0], context=context)
34
assert res.product_qty == 175.00, "Bad quantity on procurement order for Threshold 1"
36
I create a threshold rule for product2
38
!record {model: threshold.value, id: threshold2}:
41
uom_id: product.product_uom_unit
42
location_id: stock.stock_location_stock
44
threshold_manual_ok: False
46
qty_order_manual_ok: False
54
!python {model: procurement.order}: |
55
self.run_threshold_value(cr, uid, False, context={})
57
I check if a procurement order was created
59
!python {model: procurement.order}: |
60
res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold2')], context=context)
61
assert not res_ids, "Procurement created for product 2"
63
I create a threshold rule for product3
65
!record {model: threshold.value, id: threshold3}:
68
uom_id: product.product_uom_unit
69
location_id: stock.stock_location_stock
70
threshold_value: 250.0
71
threshold_manual_ok: True
73
qty_order_manual_ok: False
81
!python {model: procurement.order}: |
82
self.run_threshold_value(cr, uid, False, context={})
84
I check if a procurement order was created
86
!python {model: procurement.order}: |
87
res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold3')], context=context)
88
assert not res_ids, "Procurement created for product 3"
90
I create a threshold rule for product4
92
!record {model: threshold.value, id: threshold4}:
95
uom_id: product.product_uom_unit
96
location_id: stock.stock_location_stock
97
threshold_value: 250.00
98
threshold_manual_ok: True
100
qty_order_manual_ok: False
108
!python {model: procurement.order}: |
109
self.run_threshold_value(cr, uid, False, context={})
111
I check if a procurement order was created
113
!python {model: procurement.order}: |
114
res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold4')], context=context)
115
assert res_ids, "No procurement created for product 4"
116
res = self.browse(cr, uid, res_ids[0], context=context)
117
assert res.product_qty == 75.00, "Bad quantity on procurement order for Threshold 4"
119
I create a threshold rule for product5
121
!record {model: threshold.value, id: threshold5}:
124
uom_id: product.product_uom_unit
125
location_id: stock.stock_location_stock
126
threshold_value: 0.00
127
threshold_manual_ok: False
129
qty_order_manual_ok: True
137
!python {model: procurement.order}: |
138
self.run_threshold_value(cr, uid, False, context={})
140
I check if a procurement order was created
142
!python {model: procurement.order}: |
143
res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold5')], context=context)
144
assert res_ids, "No procurement created for product 5"
145
res = self.browse(cr, uid, res_ids[0], context=context)
146
assert res.product_qty == 150.00, "Bad quantity on procurement order for Threshold 5"
148
I create a threshold rule for product6
150
!record {model: threshold.value, id: threshold6}:
153
uom_id: product.product_uom_unit
154
location_id: stock.stock_location_stock
155
threshold_value: 250.00
156
threshold_manual_ok: True
158
qty_order_manual_ok: True
166
!python {model: procurement.order}: |
167
self.run_threshold_value(cr, uid, False, context={})
169
I check if a procurement order was created
171
!python {model: procurement.order}: |
172
res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold6')], context=context)
173
assert res_ids, "No procurement created for product 6"
174
res = self.browse(cr, uid, res_ids[0], context=context)
175
assert res.product_qty == 150.00, "Bad quantity on procurement order for Threshold 6"
177
I create a threshold rule for product7
179
!record {model: threshold.value, id: threshold7}:
182
uom_id: product.product_uom_unit
183
location_id: stock.stock_location_stock
184
threshold_value: 250.00
185
threshold_manual_ok: True
187
qty_order_manual_ok: True
195
!python {model: procurement.order}: |
196
self.run_threshold_value(cr, uid, False, context={})
198
I check if a procurement order was created
200
!python {model: procurement.order}: |
201
res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold7')], context=context)
202
assert not res_ids, "Procurement created for product 7"
204
I create a threshold rule for product8
206
!record {model: threshold.value, id: threshold8}:
209
uom_id: product.product_uom_unit
210
location_id: stock.stock_location_stock
211
threshold_value: 0.00
212
threshold_manual_ok: False
214
qty_order_manual_ok: False
222
!python {model: procurement.order}: |
223
self.run_threshold_value(cr, uid, False, context={})
225
I check if a procurement order was created
227
!python {model: procurement.order}: |
228
res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold8')], context=context)
229
assert res_ids, "No procurement created for product 8"
230
res = self.browse(cr, uid, res_ids[0], context=context)
231
assert res.product_qty == 150.00, "Bad quantity on procurement order for Threshold 8"
233
I create a threshold rule for product9
235
!record {model: threshold.value, id: threshold9}:
238
location_id: stock.stock_location_stock
239
threshold_value: 250.00
240
threshold_manual_ok: True
242
qty_order_manual_ok: False
250
!python {model: procurement.order}: |
251
self.run_threshold_value(cr, uid, False, context={})
253
I check if a procurement order was created
255
!python {model: procurement.order}: |
256
res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold9')], context=context)
257
assert len(res_ids) == 1, "Too procurement created for threshold 9"
258
res = self.browse(cr, uid, res_ids[0], context=context)
259
assert res.product_id.id == ref('product9'), "No procurement created for product 9"
260
assert res.product_qty == 175.00, "Bad quantity on procurement order for Threshold 9"
262
I create a threshold rule for product11
264
!record {model: threshold.value, id: threshold11}:
267
location_id: stock.stock_location_stock
268
threshold_value: 0.00
269
threshold_manual_ok: False
271
qty_order_manual_ok: False
279
!python {model: procurement.order}: |
280
self.run_threshold_value(cr, uid, False, context={})
282
I check if a procurement order was created
284
!python {model: procurement.order}: |
285
res_ids = self.search(cr, uid, [('name', '=', 'Threshold value: Threshold11')], context=context)
286
assert len(res_ids) == 1, "Too procurement created for threshold 11"
287
res = self.browse(cr, uid, res_ids[0], context=context)
288
assert res.product_id.id == ref('product11'), "Bad product on procurement order for Threshold 11"
289
assert res.product_qty == 175.00, "Bad quantity on procurement order for Threshold 1"
b'\\ No newline at end of file'