From 8a6e2caa04cbe9d3fd33b226146485725f7fceb0 Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Fri, 19 Jul 2019 13:43:46 +0000 Subject: [PATCH] [FIX] project: dup with subtask in another project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enable the subtasks in the settings. Create two project "A" and "B", create two tasks "A.a" and "B.b". Set the parent task of "B.b" to "A.a". ╭─ Project A ─╮ ╭─ Project B ─╮ │ │┏━parent━┿━━━▶ B.b │ │ A.a ━━━━┿┛ ╰─────────────╯ ╰─────────────╯ In normal situation, each task and subtasks are in the same subproject, in such case, the parent task has been duplicated and it is important to relink duplicated subtasks to the new parent task. In the case the parent task is not within the current project, the subtask cannot be relinked to a duplicated parent as it does not exist. We could either let the link as is or remove it, we decided to remove the link. opw-2037623 closes odoo/odoo#35023 Signed-off-by: Julien Castiaux --- addons/project/models/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 411f56aac63..6d3cfca89eb 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -292,7 +292,7 @@ class Project(models.Model): defaults = self._map_tasks_default_valeus(task) if task.parent_id: # set the parent to the duplicated task - defaults['parent_id'] = old_to_new_tasks[task.parent_id.id] + defaults['parent_id'] = old_to_new_tasks.get(task.parent_id.id, False) new_task = task.copy(defaults) old_to_new_tasks[task.id] = new_task.id tasks += new_task