From 52b69e9de4274ec75aa85dfb5300d773741078f7 Mon Sep 17 00:00:00 2001 From: ska-ibees Date: Sat, 31 Dec 2022 09:43:03 +0000 Subject: [PATCH] [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) --- addons/project/models/project.py | 2 +- addons/project/tests/test_project_subtasks.py | 2 +- doc/cla/corporate/ibees-consulting.md | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 doc/cla/corporate/ibees-consulting.md diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 95fa86bf931..0f8bd318e68 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -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 diff --git a/addons/project/tests/test_project_subtasks.py b/addons/project/tests/test_project_subtasks.py index 864c6bca7f3..70860b6e6e7 100644 --- a/addons/project/tests/test_project_subtasks.py +++ b/addons/project/tests/test_project_subtasks.py @@ -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}), ], }) diff --git a/doc/cla/corporate/ibees-consulting.md b/doc/cla/corporate/ibees-consulting.md new file mode 100644 index 00000000000..a2fc14fa58d --- /dev/null +++ b/doc/cla/corporate/ibees-consulting.md @@ -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 \ No newline at end of file