From ead6c034053c623fbe282fd4d1f06b757e8ee07d Mon Sep 17 00:00:00 2001 From: Yash Vaishnav Date: Wed, 24 May 2023 10:29:25 +0000 Subject: [PATCH] [IMP] project: task cannot be assigned as its own parent task Before this commit In the task's form view, the parent field shows the other task but also shows the current task. In this commit, the domain is applied, ensuring that the id is not the same as the current id. As a result, the parent field of the task does not include itself task-3330841 closes odoo/odoo#122286 Signed-off-by: Xavier Bol (xbo) --- addons/project/models/project_task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/project/models/project_task.py b/addons/project/models/project_task.py index bd416f076dc..06526da8302 100644 --- a/addons/project/models/project_task.py +++ b/addons/project/models/project_task.py @@ -189,7 +189,7 @@ class Task(models.Model): # In the domain of displayed_image_id, we couln't use attachment_ids because a one2many is represented as a list of commands so we used res_model & res_id displayed_image_id = fields.Many2one('ir.attachment', domain="[('res_model', '=', 'project.task'), ('res_id', '=', id), ('mimetype', 'ilike', 'image')]", string='Cover Image') - parent_id = fields.Many2one('project.task', string='Parent Task', index=True) + parent_id = fields.Many2one('project.task', string='Parent Task', index=True, domain="['!', ('id', 'child_of', id)]") child_ids = fields.One2many('project.task', 'parent_id', string="Sub-tasks", domain="[('recurring_task', '=', False)]") subtask_count = fields.Integer("Sub-task Count", compute='_compute_subtask_count') closed_subtask_count = fields.Integer("Closed Sub-tasks Count", compute='_compute_subtask_count')