Skip to content

Conversation

@amh-mw
Copy link
Member

@amh-mw amh-mw commented Sep 25, 2025

This was identified by running base module tests on an odoo:18 container with auditlog installed, yielding:

ERROR odoo odoo.addons.base.tests.test_display_name: FAIL: Subtest TestEveryModel.test_display_name_new_record [`_compute_display_name` doesn't work with new record (first onchange call).] (model='auditlog.http.session')
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/addons/base/tests/test_display_name.py", line 34, in test_display_name_new_record
    model.onchange({}, [], fields_spec)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/models/models.py", line 1019, in onchange
    snapshot1 = RecordSnapshot(record, fields_spec)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/addons/web/models/models.py", line 1106, in __init__
    self.fetch(name)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/models/models.py", line 1121, in fetch
    self[field_name] = self.record[field_name]
                       ~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 7076, in __getitem__
    return self._fields[key].__get__(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1236, in __get__
    self.recompute(record)
  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1463, in recompute
    apply_except_missing(self.compute_value, recs)
  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1436, in apply_except_missing
    func(records)
  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1485, in compute_value
    records._compute_field_value(self)
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 5295, in _compute_field_value
    fields.determine(field.compute, self)
  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 110, in determine
    return needle(*args)
           ^^^^^^^^^^^^^
  File "/usr/local/src/metricwise/oca/server-tools/auditlog/models/http_session.py", line 24, in _compute_display_name
    tz_create_date = fields.Datetime.context_timestamp(httpsession, create_date)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 2400, in context_timestamp
    assert isinstance(timestamp, datetime), 'Datetime instance expected'
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Datetime instance expected

Note: The newly created tests/test_http.py failed to provoke the issue, so it is necessary to run base tests to confirm the fix.

@amh-mw amh-mw changed the title [FIX] auditlog: Ensure display_name computation works with new record. [18.0][FIX] auditlog: Ensure display_name computation works with new record. Sep 25, 2025
@amh-mw amh-mw force-pushed the 18.0-compute_display_name branch from 19a9638 to d693007 Compare September 25, 2025 13:02
Copy link
Member

@StefanRijnhart StefanRijnhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants