[16.0][FIX] email_template_qweb: use language-aware env for rendering QWeb#1784
Conversation
thomaspaulb
left a comment
There was a problem hiding this comment.
Code approved, just the commit message should change to the OCA standard:
[FIX] email_template_qweb: use language-aware env for rendering QWeb
More detailed information... (maybe can leave out in this case, summary is clear)
NL66278
left a comment
There was a problem hiding this comment.
👍 One minor remark but for the rest LGTM
c36282d to
4ffe344
Compare
|
This PR has the |
|
@OCA/social-maintainers This is ready for merge |
|
@KKamaa Please remove the Draft: status of this PR, as that might stop people from merging. |
NL66278
left a comment
There was a problem hiding this comment.
👍 Already looked good. Now even better ;-)
|
@KKamaa Please take up my new comment and then merge commits. |
c51da58 to
479191e
Compare
| IrQweb = self_with_lang.env["ir.qweb"] | ||
|
|
||
| for res_id in template_res_ids: # ✅ use the bucketed ids | ||
| if self_with_lang.body_type == "qweb_view" and ( |
There was a problem hiding this comment.
I just noticed that this can be tested straight after line 24:
result = super().generate_email(res_ids, fields=fields)
If this is followed by
if self.body_type != "qweb_view" or (fields and "body_html" not in fields):
return result
A lot of processing can be avoided if we do not in the end modify the result anyway, and the code will have an indentation level less.
There was a problem hiding this comment.
added it, the early exit, if body isn't a qweb_view or body_html is in fields.
|
@KKamaa One more remark, check whether you agree, and still need to smash commits. |
d4d38e2 to
31b9e5b
Compare
| IrQweb = self_with_lang.env["ir.qweb"] | ||
|
|
||
| for res_id in template_res_ids: # ✅ use the bucketed ids | ||
| if self_with_lang.body_type == "qweb_view" and ( |
There was a problem hiding this comment.
So drop this if and de-indent everything that follows.
| self_with_lang = self.with_context(lang=lang) | ||
| for res_id in res_ids: | ||
| if self.body_type == "qweb_view" and ( | ||
|
|
There was a problem hiding this comment.
Also do not add blank lines everywhere. Basically, with some exceptions, the body of a method should not contain blank lines. They make it more difficult to see all the logic on one page.
8233f36 to
f7ceb71
Compare
|
@NL66278 there is a conflict coming from your branch https://github.com/Therp/social/tree/16.0-email_template_qweb-copy-view-also |
|
@OCA/social-maintainers Can somebody please merge this? |
|
/ocabot merge patch |
|
Hey, thanks for contributing! Proceeding to merge this for you. |
|
@hbrunn your merge command was aborted due to failed check(s), which you can inspect on this commit of 16.0-ocabot-merge-pr-1784-by-hbrunn-bump-patch. After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red. |
|
merging will only work after OCA/oca-addons-repo-template#333 is merged and applied to this branch |
|
@hbrunn Merging should work now, I made a PR for the repo template upgrade and it was immediately merged by Pedro. |
|
/ocabot merge patch |
|
On my way to merge this fine PR! |
|
Congratulations, your PR was merged at f796174. Thanks a lot for contributing to OCA. ❤️ |
fix bug where in email_template_qweb module: the QWeb renderer (ir.qweb) is instantiated once from the original environment (self.env) before the code switches into the per-language context: