From 205c8f6ea7e451354fade7a83c54ed64382ec9e6 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Mon, 21 Nov 2011 18:01:15 +0530 Subject: [PATCH] [IMP] mrp_operations: Improved work orders to initialize the workflow for demo data and existing records. bzr revid: uco@tinyerp.com-20111121123115-3plhb42u04ye9ipj --- addons/mrp_operations/mrp_operation_data.xml | 3 +++ addons/mrp_operations/mrp_operations.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/addons/mrp_operations/mrp_operation_data.xml b/addons/mrp_operations/mrp_operation_data.xml index 7ce25b6d250..2d0694f12ac 100644 --- a/addons/mrp_operations/mrp_operation_data.xml +++ b/addons/mrp_operations/mrp_operation_data.xml @@ -30,5 +30,8 @@ done + + + diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index 7dc93731b03..e4815fee4c6 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -552,6 +552,17 @@ class mrp_operations_operation(osv.osv): return super(mrp_operations_operation, self).create(cr, uid, vals, context=context) + def initialize_workflow_instance(self, cr, uid, context=None): + wf_service = netsvc.LocalService("workflow") + wc_line_obj = self.pool.get('mrp.production.workcenter.line') + prod_obj = self.pool.get('mrp.production') + production_ids = prod_obj.search(cr, uid, [], context=context) + for op in prod_obj.browse(cr, uid, production_ids, context=context): + wc_lines = wc_line_obj.search(cr, uid, [('production_id','=',op.id)], context=context) + for line_id in wc_lines: + wf_service.trg_create(uid, 'mrp.production.workcenter.line', line_id, cr) + return True + _columns={ 'production_id':fields.many2one('mrp.production','Production',required=True), 'workcenter_id':fields.many2one('mrp.workcenter','Work Center',required=True),