Repository navigation
Conversation
…draft
When a thanked entry is reset to draft (e.g. its bank statement line is
reconciled again), cancel_thankyou_letter() deletes its thank you and
queues a new one for the lines of the other entries. It removed the
entry's lines from object_ids as text: replace(id, "") then
replace(",,", "") glued the neighbours together ("9511504,,9511476"
became the id 95115049511476), and an id contained in another one could
be cut out of it. The new thank you missed these donations and its job
failed with MissingError.
The remaining lines are now computed as records.
Assisted-by: claude-opus-5-5, medium, claude-code
When several entries of the same thank you are reset to draft in one call (button_cancel, unlink of posted entries, multi-selection), the new thank you queued by the first one included the donations of the others. It is now only for the donations of entries still posted. Assisted-by: claude-opus-5-5, medium, claude-code
[Medium impact] The PR appears safe to merge. Reviews (1) · Last reviewed commit: "[FIX] thankyou_letters: entries of one t..." · Reviewed by Greptile |
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.
What and why
When a thanked entry is reset to draft (e.g. its bank statement line is reconciled again),
cancel_thankyou_letter()deletes its pending thank you and queues a new one for the donations of the other entries it was also for. It removed the entry's lines fromobject_idsas text:9511504,,9511476became the id95115049511476. The queued thank you job then failed withMissingErrorand the new thank you missed these two donations.button_cancel, unlink of posted entries, multi-selection), the new thank you also included the donations of the other entries reset with it.The remaining lines are now computed as records: the lines of the thank you, minus those of every entry being reset, that still exist and whose entry is posted.
Follows #2224 (same thank-you / deleted lines scenario).
Deployment notes
No upgrade needed (Python only). Communications and queue jobs already holding a glued id can be found with:
None on a copy of production of 2026-11-20.
Test evidence
Empty database,
--test-tags /thankyou_letters:TestThankYouDeletedLine: 8 tests, 0 failed.test_entry_reset_to_draft_keeps_the_other_donations(three entries of one thank you, the middle one reset to draft): with the baseaccount_move.py, FAILaccount.move.line(185189,) != account.move.line(185, 189), the glued id.test_entries_reset_to_draft_together(two of three entries reset in one call): with the first commit of this PR, FAILaccount.move.line(225, 227) != account.move.line(227,).The tests capture the job queued by
button_draft(with_delay_shpatched onaccount.move.line, called exactly once) and run it. The test helper now sets the partner on the entry, as on a bank statement entry:account.move.generate_thank_youstarts from it.Sibling paths
Invariant: after donation entries are reset to draft, their pending thank you is deleted and the job queued in its place lists exactly the donation lines of the other entries, still posted.
button_draftand, through it,button_cancel, unlink of posted entries, paymentaction_draft: all reachcancel_thankyou_letter(docstring lists them). One entry and two entries at once are tested; the others share these tests._compute_amountqueuescancel_thankyou_letterper invoice: same method. Not tested; as the review noted, it reads both payment states after the recompute, so it looks unreachable today (existing code, unchanged).action_undo_reconciliationand reconciliation rewrites delete lines without reset to draft: handled byaccount.move.line.unlinksince [FIX] thankyou_letters: forget deleted donation lines in pending thank you #2224, which already works on records.object_idsas text (searched the addons).Rules review
Run with the
code-rulesreviewer on the first commit:test_entries_reset_to_draft_together.assert_called_once).get_objects()parsesobject_idswithint()and asserts one config model. A thank you whose config is on another model, or a malformedobject_ids, would now raise here (the text code did not)._get_unsent_communications([FIX] thankyou_letters: forget deleted donation lines in pending thank you #2224) already relies on the same; not seen in data, not tested.🤖 Generated with Claude Code