Store target of field as relation

For Many2Many it replaces the relation model by the target which is what is
expected by usage in many places like the domain for email models.

Closes #13756
This commit is contained in:
Cédric Krier
2025-03-24 23:32:36 +01:00
parent 703223faf7
commit e5f0688da7
2 changed files with 5 additions and 9 deletions
+1
View File
@@ -1,3 +1,4 @@
* Store target of field as relation
* Remove support for Python 3.8
* Add support for Python 3.13
* Add on_write to ModelStorage
+4 -9
View File
@@ -344,7 +344,6 @@ class ModelField(
@classmethod
def register(cls, model, module_name, model_id):
pool = Pool()
cursor = Transaction().connection.cursor()
ir_model_field = cls.__table__()
@@ -363,17 +362,13 @@ class ModelField(
model_fields = {f['name']: f for f in cursor_dict(cursor)}
for field_name, field in model._fields.items():
if hasattr(field, 'model_name'):
relation = field.model_name
elif hasattr(field, 'relation_name'):
relation = field.relation_name
if hasattr(field, 'get_target'):
Relation = field.get_target()
relation = Relation.__name__
Model.register(Relation, module_name)
else:
relation = None
if relation:
Relation = pool.get(relation)
Model.register(Relation, module_name)
access = field_name in model.__access__
if field_name not in model_fields: