diff --git a/trytond/CHANGELOG b/trytond/CHANGELOG index ef45b607c1..eb25b70284 100644 --- a/trytond/CHANGELOG +++ b/trytond/CHANGELOG @@ -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 diff --git a/trytond/trytond/ir/model.py b/trytond/trytond/ir/model.py index c50c83974c..da21cb66f8 100644 --- a/trytond/trytond/ir/model.py +++ b/trytond/trytond/ir/model.py @@ -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: