details:   https://code.tryton.org/tryton/commit/20e3adfa8812
branch:    default
user:      Nicolas Évrard <[email protected]>
date:      Mon Apr 20 17:03:34 2026 +0200
description:
        Use last_modification as the basis of the date of ir.model.log

        Closes #14786
diffstat:

 trytond/CHANGELOG                          |   1 +
 trytond/trytond/ir/resource.py             |  44 +++++++++++++----------------
 trytond/trytond/ir/view/model_log_list.xml |   4 +-
 3 files changed, 23 insertions(+), 26 deletions(-)

diffs (115 lines):

diff -r 6952308a8b6b -r 20e3adfa8812 trytond/CHANGELOG
--- a/trytond/CHANGELOG Tue Apr 14 18:29:42 2026 +0200
+++ b/trytond/CHANGELOG Mon Apr 20 17:03:34 2026 +0200
@@ -1,3 +1,4 @@
+* Move last_user and last_modification to ResourceAccessMixin
 * Add check deliverability option to validate email tool
 * Add support for AGE to SQLite backend
 * Add button to mark notification as read
diff -r 6952308a8b6b -r 20e3adfa8812 trytond/trytond/ir/resource.py
--- a/trytond/trytond/ir/resource.py    Tue Apr 14 18:29:42 2026 +0200
+++ b/trytond/trytond/ir/resource.py    Mon Apr 20 17:03:34 2026 +0200
@@ -4,6 +4,7 @@
 from collections import defaultdict
 
 from sql.conditionals import Coalesce
+from sql.functions import DateTrunc
 
 from trytond.i18n import lazy_gettext
 from trytond.model import (
@@ -19,6 +20,15 @@
 
     resource = fields.Reference(
         "Resource", selection='get_models', required=True)
+    last_user = fields.Function(fields.Char('Last User',
+            states={
+                'invisible': ~Eval('last_user'),
+                }),
+        'get_last_user')
+    last_modification = fields.Function(fields.DateTime('Last Modification',
+            states={
+                'invisible': ~Eval('last_modification'),
+                }))
 
     @classmethod
     def __setup__(cls):
@@ -27,6 +37,7 @@
             table = cls.__table__()
             cls._sql_indexes.add(
                 Index(table, (table.resource, Index.Similarity(begin=True))))
+        cls._order.insert(0, ('last_modification', 'DESC'))
 
     @classmethod
     def default_resource(cls):
@@ -129,6 +140,15 @@
         cls.check_access([r.id for r in records], mode='create')
         return records
 
+    def get_last_user(self, name):
+        return (self.write_uid.rec_name if self.write_uid
+            else self.create_uid.rec_name)
+
+    @classmethod
+    def column_last_modification(cls, tables):
+        t, _ = tables[None]
+        return DateTrunc('second', Coalesce(t.write_date, t.create_date))
+
 
 class ResourceMixin(ResourceAccessMixin, ModelStorage, ModelView):
 
@@ -141,21 +161,10 @@
     copy_to_resources_visible = fields.Function(
         fields.Boolean("Copy to Resources Visible"),
         'on_change_with_copy_to_resources_visible')
-    last_user = fields.Function(fields.Char('Last User',
-            states={
-                'invisible': ~Eval('last_user'),
-                }),
-        'get_last_user')
-    last_modification = fields.Function(fields.DateTime('Last Modification',
-            states={
-                'invisible': ~Eval('last_modification'),
-                }),
-        'get_last_modification')
 
     @classmethod
     def __setup__(cls):
         super().__setup__()
-        cls._order.insert(0, ('last_modification', 'DESC'))
         cls.resource.required = True
 
     @fields.depends('resource')
@@ -172,19 +181,6 @@
     def on_change_with_copy_to_resources_visible(self, name=None):
         return bool(self.get_copy_to_resources())
 
-    def get_last_user(self, name):
-        return (self.write_uid.rec_name if self.write_uid
-            else self.create_uid.rec_name)
-
-    def get_last_modification(self, name):
-        return (self.write_date if self.write_date else self.create_date
-            ).replace(microsecond=0)
-
-    @staticmethod
-    def order_last_modification(tables):
-        table, _ = tables[None]
-        return [Coalesce(table.write_date, table.create_date)]
-
 
 class ResourceCopyMixin(ModelStorage):
 
diff -r 6952308a8b6b -r 20e3adfa8812 trytond/trytond/ir/view/model_log_list.xml
--- a/trytond/trytond/ir/view/model_log_list.xml        Tue Apr 14 18:29:42 
2026 +0200
+++ b/trytond/trytond/ir/view/model_log_list.xml        Mon Apr 20 17:03:34 
2026 +0200
@@ -3,8 +3,8 @@
 this repository contains the full copyright notices and license terms. -->
 <tree>
     <field name="resource" expand="2"/>
-    <field name="create_date" widget="date" string="Date"/>
-    <field name="create_date" widget="time" string="Hour"/>
+    <field name="last_modification" widget="date" string="Date"/>
+    <field name="last_modification" widget="time" string="Hour"/>
     <field name="user" expand="1"/>
     <field name="event"/>
     <field name="action" expand="1"/>

Reply via email to