90 lines
4.0 KiB
YAML
90 lines
4.0 KiB
YAML
-
|
|
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_32
|
|
product_max_qty: 15.0
|
|
product_min_qty: 5.0
|
|
product_uom: product.product_uom_unit
|
|
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_32'))
|
|
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_32'))])
|
|
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_32'))
|
|
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_32'))
|
|
|
|
context.update({'active_model': 'product.product','active_id':ref('product.product_product_32')})
|
|
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_32'),"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.
|
|
# [Note. Commented out because it spawns a thread that may query the db after tests have been reverted.]
|
|
#-
|
|
# !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)
|