details: https://code.tryton.org/tryton/commit/225529c5e779
branch: default
user: Nicolas Évrard <[email protected]>
date: Sat Dec 13 14:30:28 2025 +0100
description:
Use different starting point for IDs of table when testing
Closes #3799
diffstat:
trytond/trytond/model/modelsql.py | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diffs (43 lines):
diff -r a268eb842452 -r 225529c5e779 trytond/trytond/model/modelsql.py
--- a/trytond/trytond/model/modelsql.py Sat Dec 13 14:33:42 2025 +0100
+++ b/trytond/trytond/model/modelsql.py Sat Dec 13 14:30:28 2025 +0100
@@ -302,6 +302,7 @@
return lambda col: NullOrdering(Order(col))
+_TABLES_CREATED = set()
_TABLE_QUERY_COLUMNS = {
'create_uid': Literal(0),
'create_date': CurrentTimestamp(),
@@ -448,7 +449,9 @@
@classmethod
def __register__(cls, module_name):
transaction = Transaction()
- cursor = transaction.connection.cursor()
+ database = transaction.database
+ connection = transaction.connection
+ cursor = connection.cursor()
super().__register__(module_name)
if cls._is_table_query():
@@ -470,8 +473,20 @@
# create/update table in the database
table = cls.__table_handler__(module_name)
+ if Pool.test and cls._table not in _TABLES_CREATED:
+ database.setnextid(
+ transaction.connection, cls._table,
+ len(_TABLES_CREATED) * 500 + 1)
+ _TABLES_CREATED.add(cls._table)
+
if cls._history:
history_table = cls.__table_handler__(module_name, history=True)
+ table_history = f'{cls._table}__history'
+ if Pool.test and table_history not in _TABLES_CREATED:
+ database.setnextid(
+ transaction.connection, table_history,
+ len(_TABLES_CREATED) * 500 + 1)
+ _TABLES_CREATED.add(table_history)
for field_name, field in cls._fields.items():
if field_name == 'id':