Hi everyone,
I’ve customized the _render_qweb_pdf method in my module to inject some extra values into the _context before rendering a report.
It works perfectly when I print the report from the toolbar (Print → PDF) — the _context I added is passed correctly into the report rendering process.
However, when I click “Send by Email” (which opens the email composer with the PDF attached), the additional _context values disappear.
It seems like the context is being reset or rebuilt somewhere in the mail sending process.
Does anyone know which function or step is responsible for this context reset when using “Send by Email”? Or how to safely preserve my custom _context when generating the report attachment for the email?
Thanks in advance!
Hello,
The issue occurs because your custom context isn’t set globally - it only exists in the current environment. When you click the “Send by Email” button, the report is rendered through the mail module, which creates a new environment that doesn’t include your custom context values.