From 4fbdd7b65e82c2cd9177189b2fe794933365e12a Mon Sep 17 00:00:00 2001 From: "GPA(OpenERP)" <> Date: Wed, 3 Feb 2010 20:40:00 +0530 Subject: [PATCH] [FIX] Services product included on BOM now creates a task on Project lp bug: https://launchpad.net/bugs/494245 fixed bzr revid: jvo@tinyerp.com-20100203151000-necggy6sjs967d0z --- addons/project_mrp/mrp.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/addons/project_mrp/mrp.py b/addons/project_mrp/mrp.py index 75a04f27872..b6aaf526720 100644 --- a/addons/project_mrp/mrp.py +++ b/addons/project_mrp/mrp.py @@ -21,6 +21,7 @@ ############################################################################## from osv import fields, osv, orm +import tools class mrp_procurement(osv.osv): _name = "mrp.procurement" @@ -38,10 +39,18 @@ class mrp_procurement(osv.osv): l = line if line.order_id.project_id: content+="\n\n"+line.order_id.project_id.complete_name - + + # Creating a project for task.Project is created from Procurement. + proj_name = tools.ustr(procurement.name) + proj_exist_id = self.pool.get('project.project').search(cr, uid, [('name','=',proj_name)], context=context) + if not proj_exist_id: + project_id = self.pool.get('project.project').create(cr, uid, {'name':proj_name}) + else: + project_id = proj_exist_id[0] + self.write(cr, uid, [procurement.id], {'state':'running'}) task_id = self.pool.get('project.task').create(cr, uid, { - 'name': (procurement.origin or procurement.product_id.name) +': '+(procurement.name or ''), + 'name': '%s:%s' %(procurement.product_id.name or procurement.origin, procurement.name or ''), 'date_deadline': procurement.date_planned, 'planned_hours': procurement.product_qty, 'remaining_hours': procurement.product_qty, @@ -51,8 +60,9 @@ class mrp_procurement(osv.osv): 'description': content, 'date_deadline': procurement.date_planned, 'state': 'draft', - 'partner_id': l and l.order_id.partner_id.id or False - }) + 'partner_id': l and l.order_id.partner_id.id or False, + 'project_id': project_id, + },context=context) return task_id mrp_procurement()