[15.0][OU-FIX] hr_expense: fix account.move and lines of migrated expenses#11
Open
eantones wants to merge 4 commits into
Open
[15.0][OU-FIX] hr_expense: fix account.move and lines of migrated expenses#11eantones wants to merge 4 commits into
eantones wants to merge 4 commits into
Conversation
065dd20 to
86fa4d5
Compare
…ines fix the value of several fields on account.move and account.move.line records linked to hr.expense records. Co-authored-by: Miquel Raïch <miquel.raich@forgeflow.com>
fiscalyear_lock_date check prevent modifying old move, but some field should be recomputed to be correct in 15.0.
…k during amount recompute The payment_state rework picked from OCA#4577 rebuilt _fill_payment_state keeping only the fiscalyear_lock_date bypass, dropping the reconciliation bypass that 4ac3a16 had introduced for the same _compute_amount() pass. On databases where a reconciled expense move's recomputed amount_total disagrees with its stored line balances, the recompute fires _inverse_amount_total -> write() on reconciled lines -> UserError, aborting the whole 14->15 upgrade. Restore the upstream-merged double bypass.
…ecting, drop reconciliation bypass The double-bypass approach (4ac3a16, restored in 00451f1) lets the bare _compute_amount() call fire _inverse_amount_total through Field.__set__ -> write(): on reconciled 2-line expense moves whose recomputed amount_total is 0, the inverse rewrites both lines' debit/credit to zero — silent data corruption on reconciled entries (caught by a pre/post CSV audit: 828 mutated lines on a real 14.0 database). The reconciliation check that 4ac3a16 disables was the guard refusing exactly that write. Run the compute under env.protecting() instead: assignments land in the cache, flush() persists them by SQL, the inverse never fires, and no lock-date or reconciliation check is triggered — so the fiscalyear bypass and the reconciliation bypass both become unnecessary. Amounts follow the lines, never the other way around.
86fa4d5 to
9cdb7a6
Compare
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.
Split of #3 (hr_expense part). Disjoint file set:
openupgrade_scripts/scripts/hr_expense/15.0.2.0/post-migration.pyonly.Content labels (composable):
oca-candidate+oca-cherry-pick— each commit subject says which it is:[OCA-CHERRY-PICK OCA#4577][OCA-CHERRY-PICK OCA#4577][OCA-CANDIDATE][OCA-CANDIDATE]Submit plan: the four commits form ONE combined fix; at submit time propose the final state to OCA (coordinating with OCA PR 4577 — if it merges first, rebase and submit only our two on top).