From da99315a14934d401213b2bfdfd97103fac54b44 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Thu, 19 Sep 2024 09:49:33 +0200 Subject: [PATCH] Remove duplicated timestamps from history_revisions Closes #13528 --- trytond/trytond/model/modelsql.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/trytond/trytond/model/modelsql.py b/trytond/trytond/model/modelsql.py index f181bb25ca..2188ac3c28 100644 --- a/trytond/trytond/model/modelsql.py +++ b/trytond/trytond/model/modelsql.py @@ -674,15 +674,13 @@ class ModelSQL(ModelStorage): table = cls.__table_history__() user = User.__table__() revisions = [] + columns = [ + Coalesce(table.write_date, table.create_date), table.id, user.name] for sub_ids in grouped_slice(ids): where = reduce_ids(table.id, sub_ids) cursor.execute(*table.join(user, 'LEFT', Coalesce(table.write_uid, table.create_uid) == user.id) - .select( - Coalesce(table.write_date, table.create_date), - table.id, - user.name, - where=where)) + .select(*columns, where=where, group_by=columns)) revisions.append(cursor.fetchall()) revisions = list(chain(*revisions)) revisions.sort(reverse=True)