summaryrefslogtreecommitdiff
path: root/odoo
diff options
context:
space:
mode:
authorRémy Voet (ryv) <ryv@odoo.com>2025-01-23 16:43:03 +0100
committerJulien Carion (juca) <juca@odoo.com>2025-01-29 16:56:09 +0000
commite44bdef16f56bff5eb62062dc1df7c5685b63e1c (patch)
tree0c5bf583d7d628361b054b335bb26855e092e14f /odoo
parent08ee6f26e8e850a0e4edc912762cef1404448a72 (diff)
[IMP] core: add allow_hierachy_operators description on Field
This commit adds a description on relational fields which indicates whether it is appropriate to use the child_of/parent_of operators on them. task-4492974 Part-of: odoo/odoo#194909 Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
Diffstat (limited to 'odoo')
-rw-r--r--odoo/fields.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/odoo/fields.py b/odoo/fields.py
index 0421bc691bc..4d9899a942c 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -3111,6 +3111,11 @@ class _Relational(Field[M], typing.Generic[M]):
return f"({field_to_check} and {company_domain} or {no_company_domain}) + ({domain or []})"
return domain
+ def _description_allow_hierachy_operators(self, env):
+ """ Return if the child_of/parent_of makes sense on this field """
+ comodel = env[self.comodel_name]
+ return comodel._parent_name in comodel._fields
+
class Many2one(_Relational[M]):
""" The value of such a field is a recordset of size 0 (no