[18.0][OU-FIX] account: fill company_id and journal_id for all existing payments#22
Open
eantones wants to merge 1 commit into
Open
[18.0][OU-FIX] account: fill company_id and journal_id for all existing payments#22eantones wants to merge 1 commit into
eantones wants to merge 1 commit into
Conversation
…ng payments account.payment at 18.0 turns journal_id and company_id into its own stored required fields (in <=17.0 they were delegated to the move). The existing fill only set journal_id when the move journal is bank/cash/credit, and never set company_id at all, leaving legacy payments with NULLs in required columns: the SET NOT NULL of both columns fails at load, and the lazy ORM compute of company_id falls back to self.env.company on first edit, silently assigning the editing user company. Both values are fully derivable from the payment move: fill company_id for every payment, and fall back to the move journal for payments whose move lives outside bank/cash/credit journals, so historical rows keep their real journal and both NOT NULL constraints can install.
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.
At 18.0
account.paymentstops delegating to its move (_inheritsdropped) andjournal_id/company_idbecome the payment's own stored required fields (bothcompute=..., store=True, required=True).The current
fill_account_payment():journal_idfrom the move only when the move's journal is of typebank/cash/credit— payments whose move lives in any other journal type (e.g.general, common for netting/compensation flows) are left withjournal_id = NULL;company_idat all (the analogousfill_statement_line_fields()does fill it for statement lines).Consequences on a real 14→18 chain (measured on a production-size database: 164,706 payments):
company_idNULL on 119,930 rows (73%) andjournal_idNULL on 38,968 →unable to set NOT NULL on column company_id/journal_idat load, so both required columns end up without their NOT NULL constraint;company_id = NULLpayments behave as shared records, visible from every company;_compute_company_id()falls back toself.env.company— the first user who edits a legacy payment silently stamps their own active company on it.Both values are fully derivable from the payment's move (
move_idandmove.company_idare never NULL for legacy payments). This patch:account.payment.company_idcolumn in pre (it did not exist in ≤17.0) and fills it from the move for every payment;After the fill, both
SET NOT NULLsucceed and the schema warnings disappear.