From 3e9f312ec2e425f0a5fc412e79d6b96d85619d83 Mon Sep 17 00:00:00 2001 From: Antoine Boonen Date: Wed, 12 Jul 2023 14:20:16 +0000 Subject: [PATCH] [IMP] analytic_plan: don't allow user to choose a parent's plan which create a recursion Problem --------- When you have an analytics plans which is the parent of another one, you should not be able to choose the child plan as parent of this one. A user has the possibility to do it; when he saves, we he gets the error: Recursion Detected. Objective --------- Don't show the child plans of an analytics plan to avoid the user to choose something that raises the error. Solution --------- Update the domain of the field `parent_id` to exclude the analytic plans that are the children of the current plan. task-3414188 closes odoo/odoo#128302 Signed-off-by: Quentin De Paoli --- addons/analytic/models/analytic_plan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/analytic/models/analytic_plan.py b/addons/analytic/models/analytic_plan.py index dfa8ca3a16c..2201793f770 100644 --- a/addons/analytic/models/analytic_plan.py +++ b/addons/analytic/models/analytic_plan.py @@ -22,7 +22,7 @@ class AccountAnalyticPlan(models.Model): string="Parent", ondelete='cascade', check_company=True, - domain="[('id', '!=', id)]", + domain="['!', ('id', 'child_of', id)]", ) parent_path = fields.Char( index='btree',