Skip to content

Conversation

@P-H-Phuc
Copy link
Owner

to resolve red CI of modules that depend on edi_oca

2025-08-11 11:05:51,967 555 ERROR odoo odoo.tests.suite: ERROR: setUpClass (odoo.addons.edi_oca.tests.test_security.TestEDIExchangeRecordSecurity)
Traceback (most recent call last):
  File "/opt/odoo-venv/lib/python3.10/site-packages/odoo/addons/edi_oca/tests/common.py", line 94, in setUpClass
    cls._setup_records()
  File "/opt/odoo-venv/lib/python3.10/site-packages/odoo/addons/edi_oca/tests/test_security.py", line 53, in _setup_records
errors that caused failure (10):
2025-08-11 11:05:51,963 555 ERROR odoo odoo.sql_db: bad query: b'INSERT INTO "res_partner" ("active", "color", "create_date", "create_uid", "email", "is_company", "lang", "message_bounce", "name", "type", "tz", "user_id", "write_date", "write_uid") VALUES (true, 0, \'2025-08-11 11:05:51.620290\', 1, \'poor.partner@ododo.com\', false, \'en_US\', 0, \'Poor Partner (not integrating one)\', \'contact\', NULL, NULL, \'2025-08-11 11:05:51.620290\', 1) RETURNING "id"'
ERROR: null value in column "autopost_bills" violates not-null constraint

@thienvh332
Copy link

Hi @P-H-Phuc ,
Could you give me more context about this PR?

IMO, a base module like edi_oca should execute its tests immediately upon being loaded, to avoid test failures caused by other custom modules that depend on it.

@thienvh332
Copy link

Regarding the error you encountered, I couldn’t find a similar issue in the PRs on edi-framework, so I believe the problem originates from your PR. Please address my requests first, and then I’ll assist you with this error.

@P-H-Phuc
Copy link
Owner Author

P-H-Phuc commented Aug 15, 2025

  1. This EDIBackendTestMixin (and the test classes using it) depend on demo data
  2. The setup creates many records and might slow down installation
    If demo data isn’t loaded during installation, this reference will break and cause an error.

@thienvh332
Copy link

Summary of the outcomes regarding this issue:

The error happens because edi_purchase_edifact_oca indirectly depends on account, which introduces the required field autopost_bills on res.partner. When a new user is created in TestEDIExchangeRecordSecurity, the corresponding partner is also created, but the default value for autopost_bills is not yet loaded, resulting in a null and causing the failure.

Fix: Adds the @tagged("-at_install") decorator to the base mixin. This prevents a race condition where the parent class's setUp method may run before all module models are fully loaded. With this change, the test environment is initialized only after the Odoo environment is ready, ensuring stability.

@thienvh332
Copy link

IMO, this issue occurs due to the dependency of the edi_purchase_edifact_oca module. Therefore, the fix commit should be included in the same PR as that module, rather than being separated. 😉

@nilshamerlinck
Copy link

did you guys have a look at OCA#55 ?

@thienvh332
Copy link

thienvh332 commented Aug 20, 2025

Of course, sir. I’ve checked and made sure it doesn’t fall into your case.

This tag change in the mixin is only to inform Odoo that the mixin must wait until the environment is fully loaded before it can be used to trigger the test cases with tagged("at-install") that depend on it.

@P-H-Phuc P-H-Phuc marked this pull request as draft August 21, 2025 07:13
@thienvh332
Copy link

Hi @nilshamerlinck ,
Is there something I might have overlooked that you’ve already noticed?

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.

4 participants