[FIX] project: fix wrong subtask mapping while project copy
Steps to reproduce: 1. Install module Project 2. Enable Sub-Task feature in settings 3. Create a project A and add a task with subtasks with depth level >1. 4. Duplicate project A Issue: Duplicated child subtasks (depth >1) are not being mapped with the newly created project(duplicated one). Cause: Only mapping parent task due to wrong filter values. Solution: If the `display_project_id` of all tasks to duplicate (subtasks included) are linked to the project to duplicate, then the 'display_project_id' of duplicated tasks for those tasks will be the newly created project on all child subtasks record sets. closes odoo/odoo#115261 X-original-commit: 31a966a9a97c28c36b819e7481809f2cf4565fb5 Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
@@ -585,7 +585,7 @@ class Project(models.Model):
|
||||
new_task_ids.append(new_task.id)
|
||||
all_subtasks = new_task._get_all_subtasks()
|
||||
if all_subtasks:
|
||||
new_subtasks += new_task.child_ids.filtered(lambda child: child.display_project_id == self)
|
||||
new_subtasks += all_subtasks.filtered(lambda child: child.display_project_id == self)
|
||||
project.write({'tasks': [Command.set(new_task_ids)]})
|
||||
new_subtasks.write({'display_project_id': project.id})
|
||||
return True
|
||||
|
||||
@@ -215,7 +215,7 @@ class TestProjectSubtasks(TestProjectCommon):
|
||||
Command.create({'name': 'child 1'}),
|
||||
Command.create({'name': 'child 2', 'display_project_id': self.project_goats.id}),
|
||||
Command.create({'name': 'child 3', 'display_project_id': self.project_pigs.id}),
|
||||
Command.create({'name': 'child 4 with subtask', 'child_ids': [Command.create({'name': 'child 5'})]}),
|
||||
Command.create({'name': 'child 4 with subtask', 'child_ids': [Command.create({'name': 'child 5'}), Command.create({'name': 'child 6 with project', 'display_project_id': self.project_goats.id})]}),
|
||||
Command.create({'name': 'child archived', 'active': False}),
|
||||
],
|
||||
})
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
United Kingdom, 2022-12-31
|
||||
|
||||
iBees Consulting agrees to the terms of the Odoo Corporate Contributor License
|
||||
Agreement v1.0.
|
||||
|
||||
I declare that I am authorized and able to make this agreement and sign this
|
||||
declaration.
|
||||
|
||||
Signed,
|
||||
|
||||
iBees Consulting kamran@ibees.co.uk https://github.com/ibees-consulting
|
||||
|
||||
List of contributors:
|
||||
|
||||
Syed Kamran Ali go4site@gmail.com https://github.com/ska-ibees
|
||||
Reference in New Issue
Block a user