[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
This commit is contained in:
GPA(OpenERP) 2010-02-03 20:40:00 +05:30 committed by Jay (Open ERP)
parent 9d3a538658
commit 4fbdd7b65e
1 changed files with 14 additions and 4 deletions

View File

@ -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()