Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

StefanRijnhart
Copy link
Member

@StefanRijnhart StefanRijnhart commented Dec 27, 2024

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
Copy link
Member

@pedrobaeza pedrobaeza left a comment

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
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
9 checks passed
@OCA-git-bot
Copy link
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