Skip to content

[18.0][FIX] auditlog: move partner/user dependent tests to post_install#3565

Open
tendil wants to merge 1 commit intoOCA:18.0from
cetmix:18.0-t5248-auditlog-fix_post_install_tests
Open

[18.0][FIX] auditlog: move partner/user dependent tests to post_install#3565
tendil wants to merge 1 commit intoOCA:18.0from
cetmix:18.0-t5248-auditlog-fix_post_install_tests

Conversation

@tendil
Copy link

@tendil tendil commented Mar 19, 2026

This PR updates several auditlog test classes to run as post_install tests instead of at_install.

Why this change is needed

A subset of auditlog tests creates res.partner / res.users records in setUpClass() and setUp()
In our investigation, these tests were executed during the module loading phase, when the res.partner registry was not yet in its final state.

In that phase:

  • res.partner._fields did not contain autopost_bills
  • default_get(["autopost_bills"]) returned {}

As a result, creating a partner failed with:

psycopg2.errors.NotNullViolation: null value in column "autopost_bills"
of relation "res_partner" violates not-null constraint

The same tests executed successfully as post-tests, when the registry was fully loaded and:

  • res.partner._fields did contain autopost_bills
  • default_get(["autopost_bills"]) returned {"autopost_bills": "ask"}

Root cause

The problem was not related to auditlog method patching/reverting logic.
The issue was that these tests were running too early (at_install) while depending on a fully initialized res.partner model.

Fix

The affected test classes are now explicitly marked as:

@tagged("-at_install", "post_install")

This makes their execution phase consistent with their actual dependencies.

Why this is correct

These tests are not validating installation-time behavior.
They validate audit logging behavior on regular ORM operations and require the final registry state for res.partner / res.users

Running them as post_install is therefore the correct lifecycle for these scenarios.

Some auditlog tests create res.partner / res.users records in setUpClass()
and setUp().

During module loading, these tests may run before res.partner is fully
initialized in the registry. In that phase, the autopost_bills field is not
yet available in res.partner._fields, so partner creation can fail with a
database-level NotNullViolation.

The same scenarios work correctly as post-install tests, once the registry is
fully loaded and the field default is available.

Mark the affected test classes as post_install to align their execution phase
with their actual model dependencies.

Task: 5248
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.

1 participant