Skip to content

[19.0][FIX] stock_account: don't create missing accounts from the chart template - #6067

Closed
JordiBForgeFlow wants to merge 1 commit into
OCA:19.0from
ForgeFlow:19.0-fix-stock_account-coa-missing-records
Closed

JordiBForgeFlow wants to merge 1 commit into
OCA:19.0from
ForgeFlow:19.0-fix-stock_account-coa-missing-records

Conversation

@JordiBForgeFlow

Copy link
Copy Markdown
Member

Problem

During the migration, stock_account fills in the new stock settings of each company's accounts using the company's chart of accounts as a reference.

If a company has deleted, or never had, one of the accounts in its chart of accounts, the migration tries to create that missing account instead of skipping it. It only has the stock settings to create it with, not a name, so the migration stops with this error:

null value in column "name" of relation "account_account" violates not-null constraint

We found it migrating a Spanish company (es_pymes) that doesn't have account 310 "Raw materials A".

Fix

The migration now updates only the accounts that exist in the company and skips the missing ones, as it was meant to. It doesn't create accounts and doesn't change the result for companies that have all of them.

Assisted by AI

…plate

update_from_coa_generic() only means to fill the new stock fields on
existing records, but when a template record has those fields and the
company doesn't have it (e.g. the account was deleted), ref() returns an
empty recordset, the record passes the filter and _load_data() tries to
create it with only the stock fields:

  null value in column "name" of relation "account_account" violates
  not-null constraint

Skip template records that don't exist in the company.
@OCA-git-bot OCA-git-bot added mod:openupgrade_scripts Module openupgrade_scripts series:19.0 labels Oct 27, 2026
@JordiBForgeFlow

Copy link
Copy Markdown
Member Author

@MiquelRForgeFlow

@MiquelRForgeFlow

Copy link
Copy Markdown
Contributor

Same as #5890.

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

Labels

mod:openupgrade_scripts Module openupgrade_scripts series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants