Kuldeep Joshi(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-bug-878638-new-kjo into
lp:openobject-addons.
Requested reviews:
Bhumika (OpenERP) (sbh-openerp)
Related bugs:
Bug #878638 in OpenERP Addons: "[project] task relations (child, parent) are
not copied correctly in project copy or create from template"
https://bugs.launchpad.net/openobject-addons/+bug/878638
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-878638-new-kjo/+merge/86556
[FIX] : task relations (child, parent) are not copied correctly in project
copy
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-878638-new-kjo/+merge/86556
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-bug-878638-new-kjo.
=== modified file 'project/project.py'
--- project/project.py 2011-12-20 15:22:03 +0000
+++ project/project.py 2011-12-21 12:38:34 +0000
@@ -208,6 +208,17 @@
message = _("The project '%s' has been opened.") % name
self.log(cr, uid, id, message)
return res
+
+ def map_tasks(self,cr,uid,project_id,new_id,context=None):
+ #copy all the task manually
+ task_obj = self.pool.get('project.task')
+ proj = self.browse(cr, uid, project_id, context=context)
+ map_task_id = {}
+ for task in proj.tasks:
+ map_task_id[task.id] = task_obj.copy(cr, uid, task.id, {}, context=context)
+ self.write(cr, uid, new_id, {'tasks':[(6,0, map_task_id.values())]})
+ task_obj.duplicate_task(cr, uid, map_task_id, context=context)
+ return True
def copy(self, cr, uid, id, default={}, context=None):
if context is None:
@@ -216,29 +227,23 @@
default = default or {}
context['active_test'] = False
default['state'] = 'open'
+ default['tasks'] = []
proj = self.browse(cr, uid, id, context=context)
if not default.get('name', False):
default['name'] = proj.name + _(' (copy)')
res = super(project, self).copy(cr, uid, id, default, context)
+ self.map_tasks(cr,uid,id,res,context)
return res
def template_copy(self, cr, uid, id, default={}, context=None):
- task_obj = self.pool.get('project.task')
proj = self.browse(cr, uid, id, context=context)
default['tasks'] = [] #avoid to copy all the task automaticly
res = self.copy(cr, uid, id, default=default, context=context)
- #copy all the task manually
- map_task_id = {}
- for task in proj.tasks:
- map_task_id[task.id] = task_obj.copy(cr, uid, task.id, {}, context=context)
-
- self.write(cr, uid, res, {'tasks':[(6,0, map_task_id.values())]})
- task_obj.duplicate_task(cr, uid, map_task_id, context=context)
-
+ self.map_tasks(cr,uid,id,res,context)
return res
def duplicate_template(self, cr, uid, ids, context=None):
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp