Skip to content

[FIX] auditlog: adapt exclude fields test to #3137 - #3153

Merged
OCA-git-bot merged 1 commit into
OCA:17.0from
StefanRijnhart:17.0-fix-auditlog-exclude_fields_test
Dec 27, 2024
Merged

[FIX] auditlog: adapt exclude fields test to #3137#3153
OCA-git-bot merged 1 commit into
OCA:17.0from
StefanRijnhart:17.0-fix-auditlog-exclude_fields_test

Conversation

@StefanRijnhart

@StefanRijnhart StefanRijnhart commented Dec 27, 2024

Copy link
Copy Markdown
Member

In #3137 it is prevented to create auditlogs without log lines.

In this particular test, it is tested that no log line is created for excluded fields. We would expect therefore that no auditlog is created after #3137, but depending on the setup, an log line may be created for field phone_sanitized which is not an excluded field in the test.

To fix this, the test is adapted to write another, non excluded field so that the auditlog is created in any case.

Fixes

 2024-12-21 09:28:41,268 260 ERROR odoo odoo.addons.auditlog.tests.test_auditlog: ERROR: AuditLogRuleTestForUserFields.test_02_AuditlogFull_field_exclude_write_log
Traceback (most recent call last):
  File "/opt/odoo/odoo/models.py", line 6209, in ensure_one
    _id, = self._ids
ValueError: not enough values to unpack (expected 1, got 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/__w/server-tools/server-tools/auditlog/tests/test_auditlog.py", line 557, in test_02_AuditlogFull_field_exclude_write_log
    ).ensure_one()
  File "/opt/odoo/odoo/models.py", line 6212, in ensure_one
    raise ValueError("Expected singleton: %s" % self)
ValueError: Expected singleton: auditlog.log()

Backported from #3054 by @lembregtse

In OCA#3137 it is prevented to create auditlogs without log lines.

In this particular test, it is tested that no log line is created for excluded
fields. We would expect therefore that no auditlog is created after OCA#3137, but
depending on the setup, an log line may be created for field phone_sanitized
which is not an excluded field in the test.

To fix this, the test is adapted to write another, non excluded field so that
the auditlog is created in any case.
@StefanRijnhart
StefanRijnhart force-pushed the 17.0-fix-auditlog-exclude_fields_test branch from e4e02aa to 5a50d39 Compare December 27, 2024 09:33
@StefanRijnhart StefanRijnhart added this to the 17.0 milestone Dec 27, 2024
@StefanRijnhart
StefanRijnhart marked this pull request as ready for review December 27, 2024 09:38

@pedrobaeza pedrobaeza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 17.0-ocabot-merge-pr-3153-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 5889320 into OCA:17.0 Dec 27, 2024
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at c706e9b. Thanks a lot for contributing to OCA. ❤️

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants