[IMP]Improve search view in all modules
[odoo/odoo.git] / addons / procurement / test / procurement.yml
1 -
2   For test the procurement process, First I have to apply a minimum stock rule on product
3 -
4   I create minimum stock rule for product.
5 -
6   !record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op0}:
7     company_id: base.main_company
8     location_id: stock.stock_location_stock
9     logic: max
10     name: OP/00008
11     product_id: product.product_product_cpu2
12     product_max_qty: 15.0
13     product_min_qty: 5.0
14     product_uom: product.product_uom_kgm
15     qty_multiple: 1
16     warehouse_id: stock.warehouse0
17 -
18   Check product quantity and update it, if needed for apply a minimum stock rule.
19 -
20   !python {model: product.product}: |
21     product = self.browse(cr, uid, ref('product.product_product_cpu2'))
22     if product.virtual_available < 5.0:
23         change_qty = self.pool.get('stock.change.product.qty')
24         id = change_qty.create(cr, uid, {'location_id' : ref('stock.stock_location_stock'), 'new_quantity': 4, 'product_id': product.id})
25         change_qty.change_product_qty(cr, uid, [id], {'active_model':'product.product', 'active_id': product.id, 'active_ids':[product.id]})
26     assert product.qty_available == 4,"Product quantity is not updated."
27     assert product.virtual_available < 5.0,'Virtual stock have more quantities.'
28 -
29   I run the scheduler.
30 -
31   !python {model: procurement.order}: |
32     self.run_scheduler(cr, uid)
33 -
34   I check that procurement order is based on minimum stock rule.
35 -
36   !python {model: procurement.order}: |
37     proc_ids = self.search(cr, uid, [('product_id','=', ref('product.product_product_cpu2'))])
38     assert proc_ids, 'No Procurement created.'
39     proc_order = self.browse(cr, uid, proc_ids)[0]
40     assert proc_order.product_qty == 11.0,"Procurement product quantity is not corresponded."
41 -
42   I check product quantity.
43 -
44   !python {model: product.product}: |
45     product = self.browse(cr, uid, ref('product.product_product_cpu2'))
46     assert product.virtual_available == 15.0,"After run the scheduler product's virtual stock is not updated."
47 -
48   For test the Procurement Request wizard, Again I have to update product quantity.
49 -
50   !python {model: product.product}: |
51     mk_procure = self.pool.get('make.procurement')
52     procur_order = self.pool.get('procurement.order')
53     product = self.browse(cr, uid, ref('product.product_product_cpu2'))
54
55     context.update({'active_model': 'product.product','active_id':ref('product.product_product_cpu2')})
56     values = {'warehouse_id': ref('base.main_company'), 'uom_id': ref('product.product_uom_unit'), 'qty': 5}
57     id = mk_procure.create(cr, uid, values, context)
58     procurement = mk_procure.make_procurement(cr, uid, [id], context)
59     assert product.virtual_available == 20.0, 'Virtual stock should be updated'
60
61     proc_id = procurement.get('res_id')
62     for procurement in procur_order.browse(cr, uid, [proc_id]):
63         if procurement.state == 'confirmed':
64             assert procurement.state == 'confirmed',"Procurement state should be 'Confirmed'."
65             assert procurement.product_id.id == ref('product.product_product_cpu2'),"Product is not correspond."
66             assert procurement.product_qty == 5,"Product Quantity is not correspond."
67             assert procurement.product_uom.id == ref('product.product_uom_unit'),"Product's UOM is not correspond."
68     context.update({'proc': proc_id})
69 -
70   I run the scheduler.
71 -
72   !python {model: procurement.order}: |
73     self.run_scheduler(cr, uid)
74 -
75   I check the current state of procurement.
76 -
77   !python {model: procurement.order}: |
78     proc_id = context.get('proc')
79     proc = self.browse(cr, uid, [proc_id])[0]
80     assert proc.state == 'ready' or 'exception',"Procurement should be in Ready or Exception state"
81 #-
82 #  I compute minimum stock.
83 #  [Note.  Commented out because it spawns a thread that may query the db after tests have been reverted.]
84 #-
85 #  !python {model: procurement.orderpoint.compute}: |
86 #    proc_id = context.get('proc')
87 #    context.update({'active_model': 'procurement.order', 'active_id': proc_id})
88 #    id = self.create(cr, uid, {'automatic': True}, context)
89 #    self.procure_calculation(cr, uid, [id], context)