Skip to content

[OU-FIX] account: fill tax repartition document_type - #17

Merged
cursor[bot] merged 1 commit into
20.0from
cursor/ou-20-08d-tax-document-type-3e8f
Nov 12, 2026
Merged

cursor[bot] merged 1 commit into
20.0from
cursor/ou-20-08d-tax-document-type-3e8f

Conversation

@adekock11

Copy link
Copy Markdown
Owner

Symptom

Missing not-null constraint on account.tax.repartition.line.document_type

Root cause

document_type (invoice / refund) is required on account.tax.repartition.line in 19.0 and in 20.0. The 20.0 analysis does not list it as a new or changed field. Databases that started before Odoo 16 can still have NULL rows from the version that added the column: the NOT NULL constraint was never applied, and each later upgrade reports it again as a missing constraint.

Change

Account pre-migration fills NULL document_type:

  • A line that is used only on refund moves (out_refund, in_refund) and not on invoices or receipts becomes refund. Usage is read from account_move_line.tax_repartition_line_id joined to account_move.move_type.
  • Every other NULL line, including lines used on both sides or not used at all, becomes invoice. That is the document type Odoo creates first on a tax.
  • Rows that are still NULL or hold some other value are logged.

The note is on the account.tax.repartition.line / tag_ids_domain analysis line, because document_type itself has no analysis entry.

Verification

Confirmed document_type = fields.Selection(..., required=True) in Odoo 19 and Odoo 20 account.tax.repartition.line. ruff is clean. No database upgrade was run. No OCA pull request backfills this column for 20.0.

Upstream

Generic. Submit to OCA 20.0 on top of OCA#6068. The same NULL rows would warn on 17.0, 18.0 and 19.0 as well; this PR only adds the 20.0 script, which is where the warning was reported. A database that reaches 20.0 still has the NULLs, so fixing it here is enough for that upgrade.

Limitation

A line used on both invoices and refunds, or not used at all, is marked invoice. If it was actually a refund line that was never posted, the tax refund repartition is wrong until someone edits the tax. There is no other stored signal on the repartition line itself.

Open in Web Open in Cursor 

@cursor
cursor Bot merged commit 5b6a5b5 into 20.0 Nov 12, 2026
4 of 5 checks passed
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.

2 participants