diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml index af574a709cd..547bf298315 100644 --- a/addons/mrp/mrp_demo.xml +++ b/addons/mrp/mrp_demo.xml @@ -52,6 +52,8 @@ + + Repairs workshop diff --git a/addons/mrp/test/order_process.yml b/addons/mrp/test/order_process.yml index 8c023325232..0c970d7d196 100644 --- a/addons/mrp/test/order_process.yml +++ b/addons/mrp/test/order_process.yml @@ -55,7 +55,6 @@ - !python {model: mrp.production}: | order = self.browse(cr, uid, ref("mrp_production_shelf100cm"), context=context) - routing = order.routing_id assert len(order.workcenter_lines), "Workcenter lines are not generated proper." for line in order.workcenter_lines: wc = line.workcenter_id diff --git a/addons/mrp_operations/__openerp__.py b/addons/mrp_operations/__openerp__.py index 8d144762ef9..10d82cfb8c4 100644 --- a/addons/mrp_operations/__openerp__.py +++ b/addons/mrp_operations/__openerp__.py @@ -67,10 +67,9 @@ So that we can compare the theoretic delay and real delay. ], 'demo_xml': ['mrp_operation_data.xml', 'mrp_operations_demo.yml'], - 'test': ['test/check_mo2operations.yml', - 'test/check_operations2mo.yml', - 'test/check_mo_cancel.yml', - 'test/mrp_operations_report.yml'], + 'test': [ + 'test/workcenter_operations.yml', + ], 'installable': True, 'active': False, 'certificate': '0056233813133', diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index e6f5aa00f28..7bdb883e98e 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -350,6 +350,7 @@ class mrp_production(osv.osv): if l.production_id and (l.production_id.date_start < po.date_finished): self.write(cr, uid, [l.production_id.id], {'date_start': po.date_finished}) break + return True def write(self, cr, uid, ids, vals, context=None, update=True, mini=True): @@ -371,13 +372,13 @@ class mrp_production(osv.osv): pass return result - def action_compute(self, cr, uid, ids, properties=[]): + def action_compute(self, cr, uid, ids, properties=[], context=None): """ Computes bills of material of a product and planned date of work order. @param properties: List containing dictionaries of properties. @return: No. of products. """ - result = super(mrp_production, self).action_compute(cr, uid, ids, properties=properties) - self._compute_planned_workcenter(cr, uid, ids, context={}) + result = super(mrp_production, self).action_compute(cr, uid, ids, properties=properties, context=context) + self._compute_planned_workcenter(cr, uid, ids, context=context) return result mrp_production() diff --git a/addons/mrp_operations/test/check_mo2operations.yml b/addons/mrp_operations/test/check_mo2operations.yml deleted file mode 100644 index c5165ded1c3..00000000000 --- a/addons/mrp_operations/test/check_mo2operations.yml +++ /dev/null @@ -1,59 +0,0 @@ -- - In order to test effect of relation between production orders and work orders, first I will see how changing production order will effect work orders, -- - I am computing the data. -- - !python {model: mrp.production}: | - self.action_compute(cr, uid, [ref("mrp_production_op")], {"lang": "en_US", "tz": - 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 are two work orders generated for this production order. -- - !assert {model: mrp.production, id: mrp_production_op, string: There are 2 work orders.}: - - len(workcenter_lines) == 2 -- - The production order is Waiting Goods, so I force reservation of components. -- - !python {model: mrp.production}: - self.force_production(cr, uid, [ref("mrp_production_op")]) -- - Now I start the production order. -- - !workflow {model: mrp.production, action: button_produce, ref: mrp_production_op} -- - I check that the related work order is in progress state. -- - !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 products by clicking on 'Produce'. -- - !python {model: mrp.product.produce}: | - 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 all the related work orders for this production order are 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, _('The work orders related to this production order are not done yet!') diff --git a/addons/mrp_operations/test/check_mo_cancel.yml b/addons/mrp_operations/test/check_mo_cancel.yml deleted file mode 100644 index 2a8f58b2a37..00000000000 --- a/addons/mrp_operations/test/check_mo_cancel.yml +++ /dev/null @@ -1,29 +0,0 @@ -- - I check that there is one Work order generated related to the production order of 5 CPU_GEN. -- - !python {model: mrp.production.workcenter.line}: | - from tools.translate import _ - order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo1')),('state','=','draft')]) - assert order_id, _('No work order defined for this production order!') -- - In order to cancel the production order, I first cancel its picking. -- - !function {model: stock.picking, name: action_cancel}: - - model: mrp.production - eval: "[obj(ref('mrp_production_mo1')).picking_id.id]" -- - Now I cancel the production order. -- - !workflow {model: mrp.production, action: button_cancel, ref: mrp_production_mo1} -- - Now I check that the production order is cancelled. -- - !assert {model: mrp.production, id: mrp_production_mo1}: - - state == 'cancel' -- - I check that the work order related to the production order that is cancelled or not. -- - !python {model: mrp.production.workcenter.line}: | - from tools.translate import _ - order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo1')),('state','=','cancel')]) - assert order_id, _('Work order is not cancelled for this production order!') diff --git a/addons/mrp_operations/test/check_operations2mo.yml b/addons/mrp_operations/test/check_operations2mo.yml deleted file mode 100644 index aacd7e5ae3c..00000000000 --- a/addons/mrp_operations/test/check_operations2mo.yml +++ /dev/null @@ -1,51 +0,0 @@ -- - I check that there are two work orders generated for the production order of 2 CPU3. -- - !assert {model: mrp.production, id: mrp_production_op1, string: Operation is started.}: - - len(workcenter_lines) == 2 -- - I change the scheduled date of first work order and then I start it. -- - !python {model: mrp.production.workcenter.line}: | - order_ids = self.search(cr, uid, [('production_id','=', ref('mrp_production_op1'))]) - from datetime import datetime - self.write(cr, uid, [order_ids[0]], {'date_planned': datetime.today().strftime("%Y-%m-%d 10:00:00")}) - import netsvc - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order_ids[0], 'button_start_working', cr) -- - I check now the production order is in production state. -- - !assert {model: mrp.production, id: mrp_production_op1, string: Production order is started.}: - - state == 'in_production' -- - The first work order is done, so I mark it as done. -- - !python {model: mrp.production.workcenter.line}: | - order_ids = self.search(cr, uid, [('production_id','=', ref('mrp_production_op1'))]) - import netsvc - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order_ids[0], 'button_done', cr) -- - Now I start second work order then pause it and then resume it. -- - !python {model: mrp.production.workcenter.line}: | - order_ids = self.search(cr, uid, [('production_id','=', ref('mrp_production_op1'))]) - import netsvc - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order_ids[-1], 'button_start_working', cr) - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order_ids[-1], 'button_pause', cr) - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order_ids[-1], 'button_resume', cr) -- - I mark second work order as done. -- - !python {model: mrp.production.workcenter.line}: | - order_ids = self.search(cr, uid, [('production_id','=', ref('mrp_production_op1'))]) - import netsvc - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order_ids[-1], 'button_done', cr) -- - I check that the production order is now done. -- - !assert {model: mrp.production, id: mrp_production_op1}: - - state == 'done' diff --git a/addons/mrp_operations/test/mrp_operations_report.yml b/addons/mrp_operations/test/mrp_operations_report.yml deleted file mode 100644 index f0a646adf4e..00000000000 --- a/addons/mrp_operations/test/mrp_operations_report.yml +++ /dev/null @@ -1,17 +0,0 @@ -- - In order to test the PDF reports defined on a MRP Operations, we will print a Barcode Report -- - !python {model: mrp_operations.operation.code}: | - import netsvc, tools, os - (data, format) = netsvc.LocalService('report.mrp.code.barcode').create(cr, uid, [ref('mrp_operations.mrp_op_1'),ref('mrp_operations.mrp_op_2'),ref('mrp_operations.mrp_op_3'),ref('mrp_operations.mrp_op_4'),ref('mrp_operations.mrp_op_5')], {}, {}) - if tools.config['test_report_directory']: - file(os.path.join(tools.config['test_report_directory'], 'mrp_operations-barcode_report.'+format), 'wb+').write(data) - -- - In order to test the PDF reports defined on a MRP Operations, we will print Workcenter's Barcode Report -- - !python {model: mrp.workcenter}: | - import netsvc, tools, os - (data, format) = netsvc.LocalService('report.mrp.wc.barcode').create(cr, uid, [ref('mrp.mrp_workcenter_0'),ref('mrp.mrp_workcenter_1')], {}, {}) - if tools.config['test_report_directory']: - file(os.path.join(tools.config['test_report_directory'], 'mrp_operations-workcenter_barcode_report.'+format), 'wb+').write(data) diff --git a/addons/mrp_operations/test/workcenter_operations.yml b/addons/mrp_operations/test/workcenter_operations.yml new file mode 100644 index 00000000000..23fbe15c37d --- /dev/null +++ b/addons/mrp_operations/test/workcenter_operations.yml @@ -0,0 +1,120 @@ +- + I compute the production order. +- + !python {model: mrp.production}: | + order = self.browse(cr, uid, ref("mrp.mrp_production_shelf100cm"), context=context) + order.action_compute(context=context) +- + I check planned date in workcenter lines of production order. +- + !python {model: mrp.production}: | + order = self.browse(cr, uid, ref("mrp.mrp_production_shelf100cm"), context=context) + for line in order.workcenter_lines: + #TODO: to check start date of next line should be end of date of previous line. + assert line.date_planned, "Planned Start date is not computed: %s" %(line) + assert line.date_planned_end, "Planned End date is not computed: %s" %(line) + +- + I confirm the Production Order. +- + !workflow {model: mrp.production, action: button_confirm, ref: mrp.mrp_production_shelf100cm} +- + I run scheduler. +- + !python {model: procurement.order}: | + self.run_scheduler(cr, uid) +- + I forcefully close internal shipment. +- + !python {model: mrp.production}: | + self.force_production(cr, uid, [ref("mrp.mrp_production_shelf100cm")]) +- + I start production. +- + !workflow {model: mrp.production, action: button_produce, ref: mrp.mrp_production_shelf100cm} +- + Production start on first work center, so I start work operation on first work center. +- + !python {model: mrp.production}: | + import netsvc + order = self.browse(cr, uid, ref("mrp.mrp_production_shelf100cm"), context=context) + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_start_working', cr) +- + Now I pause first work operation due to technical fault of work center. +- + !python {model: mrp.production}: | + import netsvc + order = self.browse(cr, uid, ref("mrp.mrp_production_shelf100cm"), context=context) + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_pause', cr) + wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_resume', cr) +- + I resume first work operation. +- + !python {model: mrp.production}: | + import netsvc + order = self.browse(cr, uid, ref("mrp.mrp_production_shelf100cm"), context=context) + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_resume', cr) + +- + I cancel first work operation. +- + !python {model: mrp.production}: | + import netsvc + order = self.browse(cr, uid, ref("mrp.mrp_production_shelf100cm"), context=context) + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_cancel', cr) +- + I reset first work operation and start after resolve techninal fault of work center. +- + !python {model: mrp.production}: | + import netsvc + order = self.browse(cr, uid, ref("mrp.mrp_production_shelf100cm"), context=context) + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_draft', cr) + wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_start_working', cr) +- + Now Finished work of first work operation so I close that operation. +- + !python {model: mrp.production}: | + import netsvc + order = self.browse(cr, uid, ref("mrp.mrp_production_shelf100cm"), context=context) + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_done', cr) +- + Now I close other operations after start one by one. +- + !python {model: mrp.production}: | + import netsvc + order = self.browse(cr, uid, ref("mrp.mrp_production_shelf100cm"), context=context) + wf_service = netsvc.LocalService("workflow") + for work_line in order.workcenter_lines[1:]: + wf_service.trg_validate(uid, 'mrp.production.workcenter.line', work_line.id, 'button_start_working', cr) + wf_service.trg_validate(uid, 'mrp.production.workcenter.line', work_line.id, 'button_done', cr) + +- + I check that the production order is now done. +- + !python {model: mrp.production}: | + order = self.browse(cr, uid, ref("mrp.mrp_production_shelf100cm"), context=context) + print order.state + assert order.state == 'done', "Production should be closed after finished all operations." +- + I print a Barcode Report of Operation line. +- + !python {model: mrp_operations.operation.code}: | + import netsvc, tools, os + (data, format) = netsvc.LocalService('report.mrp.code.barcode').create(cr, uid, [ref('mrp_operations.mrp_op_1'),ref('mrp_operations.mrp_op_2'),ref('mrp_operations.mrp_op_3'),ref('mrp_operations.mrp_op_4'),ref('mrp_operations.mrp_op_5')], {}, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'mrp_operations-barcode_report.'+format), 'wb+').write(data) + +- + I print Workcenter's Barcode Report. +- + !python {model: mrp.workcenter}: | + import netsvc, tools, os + (data, format) = netsvc.LocalService('report.mrp.wc.barcode').create(cr, uid, [ref('mrp.mrp_workcenter_0'),ref('mrp.mrp_workcenter_1')], {}, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'mrp_operations-workcenter_barcode_report.'+format), 'wb+').write(data)