Browse Source
[MIG] mail_compose_select_lang: Migrated to 10.0
[MIG] mail_compose_select_lang: Migrated to 10.0
Note this migration comes with a feature loss as translated reports is no longer possible via a python override (translations are done in the report templates themselves; therefore every report would need an inherited version). This module was migrated from 8.0 to 10.0 directly, which explains the consequent diff.pull/101/head
Damien Bouvy
8 years ago
No known key found for this signature in database
GPG Key ID: 1D0AB759B4B928E3
8 changed files with 63 additions and 64 deletions
-
14mail_compose_select_lang/README.rst
-
6mail_compose_select_lang/__manifest__.py
-
3mail_compose_select_lang/models/__init__.py
-
20mail_compose_select_lang/models/email_template.py
-
22mail_compose_select_lang/models/mail_template.py
-
20mail_compose_select_lang/models/report.py
-
29mail_compose_select_lang/wizard/mail_compose_message.py
-
11mail_compose_select_lang/wizard/mail_compose_message_view.xml
@ -1,20 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# (c) 2015 Pedro M. Baeza |
|||
# License AGPL-3 - See LICENSE file on root folder for details |
|||
############################################################################## |
|||
from openerp import models, api |
|||
|
|||
|
|||
class EmailTemplate(models.Model): |
|||
_inherit = 'email.template' |
|||
|
|||
@api.model |
|||
def get_email_template_batch(self, template_id=False, res_ids=None): |
|||
if template_id and res_ids and self.env.context.get('force_lang'): |
|||
template = self.env['email.template'].with_context( |
|||
lang=self.env.context['force_lang']).browse(template_id) |
|||
return dict.fromkeys(res_ids, template) |
|||
else: |
|||
return super(EmailTemplate, self).get_email_template_batch( |
|||
template_id=template_id, res_ids=res_ids) |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# (c) 2015 Pedro M. Baeza |
|||
# License AGPL-3 - See LICENSE file on root folder for details |
|||
############################################################################## |
|||
from odoo import models, api |
|||
|
|||
|
|||
class MailTemplate(models.Model): |
|||
_inherit = 'mail.template' |
|||
|
|||
@api.model |
|||
def get_email_template(self, res_ids): |
|||
""" |
|||
Rebrowse a template with force_lang context key if it is set. |
|||
""" |
|||
if self.ids and res_ids and self.env.context.get('force_lang'): |
|||
self.ensure_one() # keep behaviour consistent with super function |
|||
template = self.with_context(lang=self.env.context['force_lang']) |
|||
return dict.fromkeys(res_ids, template) |
|||
else: |
|||
return super(MailTemplate, self).get_email_template(res_ids) |
@ -1,20 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# (c) 2015 Pedro M. Baeza |
|||
# License AGPL-3 - See LICENSE file on root folder for details |
|||
############################################################################## |
|||
from openerp import models, api |
|||
|
|||
|
|||
class Report(models.Model): |
|||
_inherit = 'report' |
|||
|
|||
@api.model |
|||
def translate_doc(self, doc_id, model, lang_field, template, values): |
|||
if self.env.context.get('force_lang'): |
|||
obj = self.with_context(lang=self.env.context['force_lang'], |
|||
translatable=True) |
|||
else: |
|||
obj = self |
|||
return super(Report, obj).translate_doc( |
|||
doc_id, model, lang_field, template, values) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue