[FIX] stock_account: skip accounts that don't exist yet in company_data - #5887
Closed
quoc-pn wants to merge 1 commit into
Closed
[FIX] stock_account: skip accounts that don't exist yet in company_data#5887quoc-pn wants to merge 1 commit into
quoc-pn wants to merge 1 commit into
Conversation
update_from_coa_generic() included a record_id in filtered_records whenever the target field appeared unset. But when ref_or_id() can't resolve the xmlid to an existing account.account record, indexing the field on the resulting empty recordset is also falsy, so a not-yet-existing account was treated the same as an existing account with the field unset. AccountChartTemplate._load_data() then created a new account.account row from only the partial company_data (the 2 stock-account fields), missing required fields like name/account_type, causing: null value in column "name" of relation "account_account" violates not-null constraint Skip record_ids that don't resolve to an existing record instead of partially-creating them.
Contributor
|
Conflicts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Follow-up to #5885, which fixed the case where a record already exists but the target field is already set. There is still a related bug for records that don't exist yet.
update_from_coa_generic()instock_account/19.0.1.1/end-migration.pybuildsfiltered_records[record_id]based on whether the target field appears unset vianot ref_or_id(record_id, model_name)[key]. Whenref_or_id()can't resolve the xmlid to an existingaccount.account(the account hasn't been created yet in this company's chart), indexing[key]on the resulting empty recordset is also falsy — so a not-yet-existing account is treated the same as an existing account with the field unset.AccountChartTemplate._load_data(company_data)then creates a newaccount.accountrow from only the partialcompany_data(just the 2 stock-account fields), missing required fields likename/account_type, causing:Fix
Skip
record_ids that don't resolve to an existing record instead of partially-creating them. This script is meant to backfill fields on existing accounts, not create new ones.Test
Reproduced during a 19.0 migration where
stock_account'send-migration.pycrashed onAccountChartTemplate._load_data()with the above error even after #5885; confirmed the crash disappears with this fix applied.