Skip to content
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

Conversation

@ror-odoo ror-odoo force-pushed the master-mail-template-lang_specific_preview-axj branch 4 times, most recently from 7607c86 to 964be8d Compare August 31, 2017 05:00
@atp-odoo atp-odoo force-pushed the master-mail-template-lang_specific_preview-axj branch from 4f95b8f to 810afc6 Compare September 5, 2017 12:12
@ror-odoo ror-odoo force-pushed the master-mail-template-lang_specific_preview-axj branch from 810afc6 to 49a8d3c Compare September 7, 2017 10:18
@C3POdoo C3POdoo added the RD research & development, internal work label Sep 13, 2017
@mba-odoo mba-odoo force-pushed the master-mail-template-lang_specific_preview-axj branch 2 times, most recently from 9db30fe to 499590a Compare November 3, 2017 06:24
@dka-odoo dka-odoo force-pushed the master-mail-template-lang_specific_preview-axj branch 6 times, most recently from e4e5513 to 3f516f7 Compare January 3, 2018 13:04
@hmo-odoo hmo-odoo added the Services Project, timesheet, helpdesk,... label Mar 20, 2018
@mba-odoo mba-odoo force-pushed the master-mail-template-lang_specific_preview-axj branch 2 times, most recently from 0cf643f to 03d7399 Compare May 9, 2018 06:13
@mba-odoo mba-odoo force-pushed the master-mail-template-lang_specific_preview-axj branch 4 times, most recently from 35d5a7f to c822809 Compare May 22, 2018 12:16
@mba-odoo
Copy link
Contributor

LGTM

Copy link
Contributor

@tde-banana-odoo tde-banana-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technical validation

@@ -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)
Copy link
Contributor

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'):
Copy link
Contributor

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.

Copy link
Contributor

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

@mba-odoo mba-odoo force-pushed the master-mail-template-lang_specific_preview-axj branch 4 times, most recently from 4d6c6fd to f85cb6e Compare June 5, 2018 06:05
@mart-e mart-e force-pushed the master-mail-template-lang_specific_preview-axj branch from f85cb6e to e1b1662 Compare February 7, 2019 11:21
@robodoo robodoo added the CI 🤖 Robodoo has seen passing statuses label Feb 7, 2019
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
@tde-banana-odoo tde-banana-odoo force-pushed the master-mail-template-lang_specific_preview-axj branch from e1b1662 to 5439e38 Compare April 24, 2019 13:35
@robodoo robodoo removed the CI 🤖 Robodoo has seen passing statuses label Apr 24, 2019
@tde-banana-odoo
Copy link
Contributor

@robodoo r+

@robodoo robodoo added r+ 👌 CI 🤖 Robodoo has seen passing statuses labels Apr 24, 2019
robodoo pushed a commit that referenced this pull request Apr 24, 2019
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>
@robodoo
Copy link
Contributor

robodoo commented Apr 24, 2019

Merged, thanks!

@robodoo robodoo closed this Apr 24, 2019
@tde-banana-odoo tde-banana-odoo deleted the master-mail-template-lang_specific_preview-axj branch May 6, 2019 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI 🤖 Robodoo has seen passing statuses RD research & development, internal work Services Project, timesheet, helpdesk,...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants