Add model attribute to table handler

This commit is contained in:
Cédric Krier committed 2026-03-14 18:12:02 +01:00
1 parent 2b626f1708
commit 33856ac2a1
4 files changed
+8 -6

No files matched your search

+4
View File
@@ -253,6 +253,10 @@ TableHandler
Handle table for the ``model``.
If ``history`` is set, the table is the one storing the history.
.. attribute:: TableHandler.model
The :class:`~trytond.model.ModelSQL` of the handled table.
.. attribute:: TableHandler.history
A boolean to handle the history table.
+1 -2
View File
@@ -28,7 +28,6 @@ class TableHandler(TableHandlerInterface):
self.__constraints = None
self.__fk_deltypes = None
self.__indexes = None
self._model = model
transaction = Transaction()
cursor = transaction.connection.cursor()
@@ -188,7 +187,7 @@ class TableHandler(TableHandlerInterface):
if not self.history:
history_table = self.table_name + '__history'
if self.__class__.table_exist(history_table):
history_h = self.__class__(self._model, True)
history_h = self.__class__(self.model, True)
history_h.column_rename(old_name, new_name)
else:
logger.warning(
+2 -3
View File
@@ -29,7 +29,6 @@ class TableHandler(TableHandlerInterface):
super()._init(model, history=history)
self.__columns = None
self.__indexes = None
self._model = model
cursor = Transaction().connection.cursor()
# Create new table if necessary
@@ -90,7 +89,7 @@ class TableHandler(TableHandlerInterface):
temp_table = '__temp_%s' % self.table_name
temp_columns = dict(self._columns)
self.table_rename(self.table_name, temp_table)
self._init(self._model, history=self.history)
self._init(self.model, history=self.history)
columns, old_columns = [], []
for name, values in temp_columns.items():
if name in drop_columns:
@@ -125,7 +124,7 @@ class TableHandler(TableHandlerInterface):
if not self.history:
history_table = self.table_name + '__history'
if self.__class__.table_exist(history_table):
history_h = self.__class__(self._model, True)
history_h = self.__class__(self.model, True)
history_h.column_rename(old_name, new_name)
else:
logger.warning(
+1 -1
View File
@@ -34,7 +34,7 @@ class TableHandlerInterface(object):
self.table_name = model._table + '__history'
else:
self.table_name = model._table
self.object_name = model.__name__
self.model = model
if history:
self.sequence_name = self.table_name + '___id_seq'
else: