[FIX] Allow report/template generation outside an HTTP request - #112
Open
Rad0van wants to merge 2 commits into
Open
[FIX] Allow report/template generation outside an HTTP request#112Rad0van wants to merge 2 commits into
Rad0van wants to merge 2 commits into
Conversation
onlyoffice_request/onlyoffice_urlopen read request.env directly, which raises "object is not bound" when called from the shell, cron or server actions. Add an optional env parameter (via _resolve_env) that falls back to request.env, so callers without a bound request can pass their own environment.
Thread self.env into onlyoffice_request calls in the model layer (ir_actions_report report stream fetch and fill_template docbuilder posts, and the template conversion/create paths) so report and template generation works when invoked outside of an HTTP request (shell, cron, mail rendering).
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.
Problem
onlyoffice_request()andonlyoffice_urlopen()inonlyoffice_odoo/controllers/controllers.pyreadrequest.envdirectly.requestis a werkzeug local proxy that is only bound during an HTTP request, so any code path that triggers ONLYOFFICE report/template generation outside of a web request fails with:This happens when generating an ONLYOFFICE-backed report from:
ir.cronjob,A real-world trigger is sending a
mail.templatewhose report attachment is an ONLYOFFICE template, from a scheduled/cron context.Fix
Add an optional
envparameter to both helpers, resolved through a small_resolve_env(env)that falls back torequest.envwhen nothing is passed. Model-layer callers (ir_actions_reportandonlyoffice_odoo_templates) now passenv=self.env.This is fully backward compatible: every existing controller call site (where
requestis bound) passes nothing and behaves exactly as before.Changes
onlyoffice_odoo:onlyoffice_request/onlyoffice_urlopenacceptenv=None(falls back torequest.env).onlyoffice_odoo_templates: passenv=self.envat the model-layer call sites (report stream fetch,fill_templatedocbuilder posts, template conversion/create paths).ruff checkpasses on all changed files.🤖 Generated with Claude Code