[MERGE] procurement: add tests

bzr revid: rco@openerp.com-20111216133330-0s3fau4ptf0b5tr0
This commit is contained in:
Raphael Collet 2011-12-16 14:33:30 +01:00
commit 3deb1083c9
3 changed files with 90 additions and 2 deletions

View File

@ -59,6 +59,7 @@ depending on the product's configuration.
'board_mrp_procurement_view.xml',
],
'demo_xml': ['stock_orderpoint.xml'],
'test': ['test/procurement.yml'],
'installable': True,
'active': False,
'certificate': '00954248826881074509',

View File

@ -63,7 +63,6 @@ mrp_property()
class StockMove(osv.osv):
_inherit = 'stock.move'
_columns= {
'procurements': fields.one2many('procurement.order', 'move_id', 'Procurements'),
}
@ -482,7 +481,7 @@ class StockPicking(osv.osv):
if move.state == 'done' and move.procurements:
for procurement in move.procurements:
wf_service.trg_validate(user, 'procurement.order',
procurement.id, 'button_check', cursor)
procurement.id, 'button_check', cursor)
return res
StockPicking()

View File

@ -0,0 +1,88 @@
-
For test the procurement process, First I have to apply a minimum stock rule on product
-
I create minimum stock rule for product.
-
!record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op0}:
company_id: base.main_company
location_id: stock.stock_location_stock
logic: max
name: OP/00008
product_id: product.product_product_cpu2
product_max_qty: 15.0
product_min_qty: 5.0
product_uom: product.product_uom_kgm
qty_multiple: 1
warehouse_id: stock.warehouse0
-
Check product quantity and update it, if needed for apply a minimum stock rule.
-
!python {model: product.product}: |
product = self.browse(cr, uid, ref('product.product_product_cpu2'))
if product.virtual_available < 5.0:
change_qty = self.pool.get('stock.change.product.qty')
id = change_qty.create(cr, uid, {'location_id' : ref('stock.stock_location_stock'), 'new_quantity': 4, 'product_id': product.id})
change_qty.change_product_qty(cr, uid, [id], {'active_model':'product.product', 'active_id': product.id, 'active_ids':[product.id]})
assert product.qty_available == 4,"Product quantity is not updated."
assert product.virtual_available < 5.0,'Virtual stock have more quantities.'
-
I run the scheduler.
-
!python {model: procurement.order}: |
self.run_scheduler(cr, uid)
-
I check that procurement order is based on minimum stock rule.
-
!python {model: procurement.order}: |
proc_ids = self.search(cr, uid, [('product_id','=', ref('product.product_product_cpu2'))])
assert proc_ids, 'No Procurement created.'
proc_order = self.browse(cr, uid, proc_ids)[0]
assert proc_order.product_qty == 11.0,"Procurement product quantity is not corresponded."
-
I check product quantity.
-
!python {model: product.product}: |
product = self.browse(cr, uid, ref('product.product_product_cpu2'))
assert product.virtual_available == 15.0,"After run the scheduler product's virtual stock is not updated."
-
For test the Procurement Request wizard, Again I have to update product quantity.
-
!python {model: product.product}: |
mk_procure = self.pool.get('make.procurement')
procur_order = self.pool.get('procurement.order')
product = self.browse(cr, uid, ref('product.product_product_cpu2'))
context.update({'active_model': 'product.product','active_id':ref('product.product_product_cpu2')})
values = {'warehouse_id': ref('base.main_company'), 'uom_id': ref('product.product_uom_unit'), 'qty': 5}
id = mk_procure.create(cr, uid, values, context)
procurement = mk_procure.make_procurement(cr, uid, [id], context)
assert product.virtual_available == 20.0, 'Virtual stock should be updated'
proc_id = procurement.get('res_id')
for procurement in procur_order.browse(cr, uid, [proc_id]):
if procurement.state == 'confirmed':
assert procurement.state == 'confirmed',"Procurement state should be 'Confirmed'."
assert procurement.product_id.id == ref('product.product_product_cpu2'),"Product is not correspond."
assert procurement.product_qty == 5,"Product Quantity is not correspond."
assert procurement.product_uom.id == ref('product.product_uom_unit'),"Product's UOM is not correspond."
context.update({'proc': proc_id})
-
I run the scheduler.
-
!python {model: procurement.order}: |
self.run_scheduler(cr, uid)
-
I check the current state of procurement.
-
!python {model: procurement.order}: |
proc_id = context.get('proc')
proc = self.browse(cr, uid, [proc_id])[0]
assert proc.state == 'ready' or 'exception',"Procurement should be in Ready or Exception state"
-
I compute minimum stock.
-
!python {model: procurement.orderpoint.compute}: |
proc_id = context.get('proc')
context.update({'active_model': 'procurement.order', 'active_id': proc_id})
id = self.create(cr, uid, {'automatic': True}, context)
self.procure_calculation(cr, uid, [id], context)