Skip to content

[19.0][FIX] purchase_advance_payment: load a chart template in tests - #3159

Open
rahu-dynapps wants to merge 1 commit into
OCA:19.0from
ScopeaFrance:19.0-fix-purchase_advance_payment-tests-chart-template
Open

[19.0][FIX] purchase_advance_payment: load a chart template in tests#3159
rahu-dynapps wants to merge 1 commit into
OCA:19.0from
ScopeaFrance:19.0-fix-purchase_advance_payment-tests-chart-template

Conversation

@rahu-dynapps

Copy link
Copy Markdown

Problem

TestPurchaseAdvancePayment.setUpClass creates an account.tax. On a database where no chart of accounts has been loaded yet, there is no account.tax.group and no fiscal country on the company, so the record cannot be created:

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

This happens on any freshly initialized database without demo data, for instance a new build on a hosting platform that installs the module from scratch. Chart templates are only auto-loaded after the module loading phase, so the tests run before any chart is available.

The payment tests have the same underlying need: without a chart, account.payment.create raises No outstanding account could be found to make the payment.

Fix

Load generic_coa in setUpClass when the company has no chart template yet. Databases that already have a chart (a real database, or the OCA CI with demo data) are untouched by the guard.

Test

  • Fresh database, -i purchase_advance_payment --test-enable --without-demo=all: 12/12 green (fails on tax_group_id without the patch).
  • Database with a chart already loaded: 12/12 green, unchanged.

The test setup creates an account.tax, which requires both a tax group
and a fiscal country. On a database where no chart of accounts has been
loaded yet, account.tax.group is empty and account.tax.create fails on
the tax_group_id NOT NULL constraint. The payment tests then also need
journals and outstanding accounts.

Load generic_coa when the company has no chart template, so the tests
run on a freshly initialized database as well.
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @LoisRForgeFlow,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added series:19.0 mod:purchase_advance_payment Module purchase_advance_payment labels Aug 31, 2026

@LoisRForgeFlow LoisRForgeFlow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the analysis and the fix, it makes sense 👍

@LoisRForgeFlow

Copy link
Copy Markdown
Contributor

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 19.0-ocabot-merge-pr-3159-by-LoisRForgeFlow-bump-patch, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@LoisRForgeFlow your merge command was aborted due to failed check(s), which you can inspect on this commit of 19.0-ocabot-merge-pr-3159-by-LoisRForgeFlow-bump-patch.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

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

Labels

mod:purchase_advance_payment Module purchase_advance_payment series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants