[IMP]: mrp_operations: Improvements in test cases of yml, added case to check how changing MO will affect work orders

bzr revid: rpa@tinyerp.com-20111116112026-1xehagb0xtwosihm
This commit is contained in:
Rucha (Open ERP) 2011-11-16 16:50:26 +05:30
parent 4fbdd40b28
commit 718f45c360
1 changed files with 23 additions and 99 deletions

View File

@ -1,13 +1,14 @@
-
In order to test effect of operations on different work order for a Production Order I create a production order.
In order to test effect of relation between production orders and operations I create a production order.
-
First I will see how changing production order will effect work orders,
-
!record {model: mrp.production, id: mrp_production_op}:
company_id: base.main_company
date_planned: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S")
location_dest_id: stock.stock_location_stock
location_src_id: stock.stock_location_stock
name: MO/0123456
product_id: product.product_product_pc1
product_id: product.product_product_cpu3
product_qty: 5.0
product_uos_qty: 5.0
allow_reorder: True
@ -19,129 +20,52 @@
False, "search_default_current": 1, "active_model": "ir.ui.menu", "active_ids":
[ref("mrp.menu_mrp_production_action")], "active_id": ref("mrp.menu_mrp_production_action"),
})
-
I calculate planned end date of the production order.
-
!python {model: mrp.production}: |
mo = self.browse(cr, uid, ref("mrp_production_op"))
self._production_date_end(cr, uid, [ref("mrp_production_op")], mo.date_planned, False)
-
Now I confirm the production order.
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_op}
-
I check that there is one Work order generated related to my production order.
I check that there are two work orders generated for this production order.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_op')),('state','=','draft')])
assert order_id, _('No Work order define for this production order!')
!assert {model: mrp.production, id: mrp_production_op, string: Operation is started.}:
- len(workcenter_lines) == 2
-
The scheduler runs.
The production order is Waiting Goods, so I force reservation of components.
-
!function {model: procurement.order, name: run_scheduler}:
- model: procurement.order
search: "[]"
!python {model: mrp.production}:
self.force_production(cr, uid, [ref("mrp_production_op")])
-
I see that there is a manufacturing order for the sub product CPU_GEN of PC1 with ready state.
-
!python {model: mrp.production}: |
from tools.translate import _
order_ids = self.search(cr, uid, [('state','=','ready'),('origin','like','%MO/0123456')])
assert order_ids, _('No new manufacturing order!')
-
I check that there one more work order created for new production order.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
prod_obj = self.pool.get('mrp.production')
prod_order_ids = prod_obj.search(cr, uid, [('state','=','ready'),('origin','like','%MO/0123456')])
workorder_id = self.search(cr, uid, [('production_id','=', prod_order_ids[0]),('state','=','draft')])
assert workorder_id, _('No Work order define for this production order!')
-
I start the second production order of the CPU_GEN product.
-
!python {model: mrp.production}: |
import netsvc
wf_service = netsvc.LocalService("workflow")
prod_order_ids = self.search(cr, uid, [('state','=','ready'),('origin','like','%MO/0123456')])
for po in prod_order_ids:
wf_service.trg_validate(uid, 'mrp.production', po, 'button_produce', cr)
-
I am creating a mrp.product.produce record
-
!record {model: mrp.product.produce, id: mrp_product_produce_0}:
mode: consume_produce
product_qty: 5.0
-
I produce the product CPU_GEN.
-
!python {model: mrp.product.produce}: |
prod_obj = self.pool.get('mrp.production')
prod_order_ids = prod_obj.search(cr, uid, [('origin','like','%MO/0123456')])
self.do_produce(cr, uid, [ref("mrp_product_produce_0")], {"lang": "en_US", "tz":
False, "search_default_current": 1, "active_model": "mrp.production", "active_ids":
prod_order_ids, "active_id": prod_order_ids[0], })
-
I check that my production order and its related work order is in done state.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
prod_obj = self.pool.get('mrp.production')
prod_order_ids = prod_obj.search(cr, uid, [('origin','like','%MO/0123456')])
assert prod_order_ids, _('Workorder not found')
workorder_id = self.search(cr, uid, [('production_id','=', prod_order_ids[0])])
workorder_bro = self.browse(cr, uid, workorder_id[0])
assert workorder_bro.state == 'done', _('Work order is not done! It is %s') % workorder_bro.state
-
Now I check my original production order is now ready.
-
!python {model: mrp.production}: |
from tools.translate import _
prod_ids = self.search(cr, uid, [('id','=',ref('mrp_production_op')),('state','=','ready')])
assert prod_ids, _('Production order is not ready!')
-
I check that both internal pickings are done.
-
!python {model: stock.picking}: |
from tools.translate import _
pick_ids = self.search(cr, uid, [('state','=','done'),('type','=','internal')])
assert pick_ids, _('Internal pickings are not done!')
-
Now I start my first production order.
Now I start my production order.
-
!workflow {model: mrp.production, action: button_produce, ref: mrp_production_op}
-
I check that the related work order is in progress state.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_op')),('state','=','startworking')])
assert order_id, _('Work order not started yet!')
-
!assert {model: mrp.production, id: mrp_production_op, string: Operation is started.}:
- workcenter_lines[0].state == 'startworking'
-
I am creating a mrp.product.produce record.
-
!record {model: mrp.product.produce, id: mrp_product_produce_0}:
mode: consume_produce
product_qty: 5.0
-
I produce the product PC1.
I produce the products by clicking on 'Produce'
-
!python {model: mrp.product.produce}: |
prod_obj = self.pool.get('mrp.production')
prod_order_ids = prod_obj.search(cr, uid, [('state','=','in_production')])
self.do_produce(cr, uid, [ref("mrp_product_produce_0")], {"lang": "en_US", "tz":
False, "search_default_current": 1, "active_model": "mrp.production", "active_ids":
[ref("mrp_production_op")], "active_id": ref("mrp_production_op"), })
-
I check the related work order is done.
I check all the related work orders for this production order is now done.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_op')),('state','=','done')])
assert order_id, _('Work order not done yet!')
-
Calculates start date for stock moves finding interval from resource calendar.
-
!python {model: mrp.production}: |
self._move_pass(cr, uid, [ref('mrp_production_op')], context=None)
-
Calculates planned end date of production order.
-
!python {model: mrp.production}: |
mo = self.browse(cr, uid, ref("mrp_production_op"))
self._production_date_end(cr, uid, [ref("mrp_production_op")], mo.date_planned, False, context=None)
assert order_id, _('The work orders related to this production order are not done yet!')