New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Master mail template lang specific preview axj #19165
Master mail template lang specific preview axj #19165
Conversation
7607c86
to
964be8d
Compare
4f95b8f
to
810afc6
Compare
810afc6
to
49a8d3c
Compare
9db30fe
to
499590a
Compare
e4e5513
to
3f516f7
Compare
0cf643f
to
03d7399
Compare
35d5a7f
to
c822809
Compare
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technical validation
addons/mail/models/mail_template.py
Outdated
@@ -361,7 +361,8 @@ def get_email_template(self, res_ids): | |||
return results | |||
self.ensure_one() | |||
|
|||
langs = self.render_template(self.lang, self.model, res_ids) | |||
lang = self.env.context.get('template_preview_lang', self.lang) | |||
langs = self.render_template(lang, self.model, res_ids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I don't think it is the correct way of doing it. Previous code was rendering the lang field of the template, which could be a jinja template. Here we want to bypass this process and force a lang. I think it is better to a/ check for context key, then b/ if not found, render the template lang field.
if 'res_id' in fields and not result.get('res_id'): | ||
records = self._get_records() | ||
result['res_id'] = records and records[0][0] or False # select first record as a Default | ||
if self._context.get('template_id') and 'model_id' in fields and not result.get('model_id'): | ||
result['model_id'] = self.env['mail.template'].browse(self._context['template_id']).model_id.id | ||
if template and 'model_id' in fields and not result.get('model_id'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well while we are at it, add a real template_id field on this model. Let us stop playing with context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tde-banana-odoo , Even we make real template field it's not going to be used anywhere because this template_id is used to get the value of selection field(selection key, value) which is model type method. here: https://github.com/odoo/odoo/blob/master/addons/mail/wizard/email_template_preview.py#L13
and also used to get model_id which is inherited here from mail.template. so it's better to keep context. Thanks
4d6c6fd
to
f85cb6e
Compare
f85cb6e
to
e1b1662
Compare
Purpose: allow to check email preview in a specific language in order to see the result in a given translation context. Specifications * added preview_lang field to change language of template * set default language from the template by evaluating expression if lang field of template is set, This commit is related to task ID: 30245
e1b1662
to
5439e38
Compare
@robodoo r+ |
Purpose: allow to check email preview in a specific language in order to see the result in a given translation context. Specifications * added preview_lang field to change language of template * set default language from the template by evaluating expression if lang field of template is set, This commit is related to task ID: 30245 closes #19165 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Merged, thanks! |
Task : https://www.odoo.com/web?#id=30245&view_type=form&model=project.task&action=333&active_id=131&menu_id=4720
Pad: https://pad.odoo.com/p/r.cd909afd5e2214a1845d437b3bf52d66