fix: set thanks_printed when printing thanks letters via report binding#154
Open
dbruehlmeier wants to merge 1 commit intoOCA:18.0from
Open
fix: set thanks_printed when printing thanks letters via report binding#154dbruehlmeier wants to merge 1 commit intoOCA:18.0from
dbruehlmeier wants to merge 1 commit intoOCA:18.0from
Conversation
Contributor
|
Hi @alexis-via, |
42c0843 to
3720320
Compare
When printing thanks letters from the list view using multi-select, the thanks_printed flag was not set to True. Only the form view button correctly updated the flag. Replace the direct report binding with a server action that calls print_thanks(), ensuring a single code path for both single and multi-select printing. Remove the now-redundant 'Mark as Thanks Printed' list header button and thanks_printed_button() method. Add DE and FR translations for thanks-related strings and unit tests for the thanks letter printing functionality.
3720320 to
0cad797
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.
Summary
When printing thanks letters from the list view using multi-select and the Print menu (report binding), the
thanks_printedflag ondonation.donationis not set toTrue. The same action from the form view button works differently: thethanks_printedflag ondonation.donationis set automatically.I'm not sure if this is actually a feature or a bug, but from a UX perspective it's inconsistent behaviour and thus feels like a bug.
Why this approach
The root cause is that the report
donation.report_thankswas bound directly to the model viabinding_model_id. When triggered from the Print menu, Odoo's report machinery generates the PDF without ever callingprint_thanks(), so the flag is never set.I considered two alternatives before settling on the current approach:
ir.actions.report._render_qweb_pdfto set the flag whenever the thanks report is rendered. I discarded this because it patches a global model for a domain-specific concern — a disproportionate side effect for what is essentially a flag toggle. It also couples the flag-setting to the PDF rendering pipeline, which makes the behaviour harder to reason about and test._render_qweb_pdf_prepare_streams(the canonical extension point used by core modules likepurchase,account,l10n_ch). While more idiomatic than option 1, those core overrides exist to modify PDF content (embed XML, merge documents), not to set business flags. Using the same hook for a different purpose felt like a misuse of the pattern.Instead, I replaced the direct report binding with an
ir.actions.serverthat callsprint_thanks(). This follows the same pattern aspurchase.order.print_quotation()— set the flag, then return the report action — and ensures a single code path for both form and list view. No global model overrides needed.The "Mark as Thanks Printed" list header button became redundant (it only set the flag without printing) and was removed.