diff --git a/addons/mrp_operations/__openerp__.py b/addons/mrp_operations/__openerp__.py index 08f8f5b7f5b..0f1c915f62f 100644 --- a/addons/mrp_operations/__openerp__.py +++ b/addons/mrp_operations/__openerp__.py @@ -65,7 +65,7 @@ So that we can compare the theoretic delay and real delay. 'process/mrp_operation_process.xml' ], 'demo_xml': ['mrp_operation_data.xml'], - 'test': ['test/mrp_operations.yml', 'test/mrp_operations_report.yml'], + 'test': ['test/mrp_operations.yml', 'test/mrp_operations_report.yml','test/mrp_operation_test.yml'], 'installable': True, 'active': False, 'certificate': '0056233813133', diff --git a/addons/mrp_operations/test/mrp_operation_test.yml b/addons/mrp_operations/test/mrp_operation_test.yml new file mode 100644 index 00000000000..a6a5dac1670 --- /dev/null +++ b/addons/mrp_operations/test/mrp_operation_test.yml @@ -0,0 +1,62 @@ +- + In order to test mrp_operations module in OpenERP I will put a Production order + and check its effects on Work orders. +- + I create a production order. +- + !record {model: mrp.production, id: mrp_production_mo1}: + 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/01234567 + product_id: product.product_product_pc1 + product_qty: 5.0 + product_uom: product.product_uom_unit + product_uos_qty: 5.0 +- + I am computing the data. +- + !python {model: mrp.production}: | + self.action_compute(cr, uid, [ref("mrp_production_mo1")], {"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"), + }) +- + Now I confirm my production order. +- + !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1} +- + I check that there is one Work order generated related to my production order. +- + !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!') +- + The scheduler runs. +- + !function {model: procurement.order, name: run_scheduler}: + - model: procurement.order + search: "[('state','=','confirmed')]" +- + I am checking Internal picking. +- + !python {model: stock.picking}: | + from tools.translate import _ + pick_ids = self.search(cr, uid, [('state','!=','done'),('type','=','internal')]) + assert pick_ids, _('No Internal Pickings!') +- + In order to cancel the MO, I first cancel its picking +- + !python {model: stock.picking}: | + mrp_obj = self.pool.get('mrp.production') + mo = mrp_obj.browse(cr, uid, ref("mrp_production_mo1")) + picking_id = self.search(cr, uid, [('origin','like','%MO/01234567')]) + if picking_id: + self.action_cancel(cr, uid, picking_id, context=None) +- + Then I cancel The Manufacturing order. +- + !workflow {model: mrp.production, action: button_cancel, ref: mrp_production_mo1} + diff --git a/addons/mrp_operations/test/mrp_operations.yml b/addons/mrp_operations/test/mrp_operations.yml index dc193186341..af398bbc292 100644 --- a/addons/mrp_operations/test/mrp_operations.yml +++ b/addons/mrp_operations/test/mrp_operations.yml @@ -122,6 +122,19 @@ from tools.translate import _ order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo0')),('state','=','startworking')]) assert order_id, _('Work order not started yet!') +- + Modifies production order state if work order state is changed. +- + !python {model: mrp.production.workcenter.line}: | + from tools.translate import _ + prod_obj = self.pool.get('mrp.production') + order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo0'))]) + order_data = self.browse(cr, uid, order_id[0]) + if order_data.production_id.state=='confirmed': + prod_obj.force_production(cr, uid, [order_data.id]) + wf_service.trg_validate(uid, 'mrp.production', order_data.id, 'button_produce', cr) + elif order_data.production_id.state=='ready': + wf_service.trg_validate(uid, 'mrp.production', order_data.id, 'button_produce', cr) - I am creating a mrp.product.produce record. -