From b730f58ac44abce4b651b6e7a5c32cb05c22cf12 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Tue, 7 Jul 2015 18:00:56 +0200 Subject: [PATCH] [ADD] mail_compose_select_lang Select language in mail compose window ====================================== This module allows to select the language for the mail content directly in the mail compose window. It also translates attachments that can be linked to the email template. Usage ===== By default, mail compose window will use corresponding language for showing the contents, but you will be able to select another language from the dropdown box "Force language" in the bottom right part. --- mail_compose_select_lang/README.rst | 50 ++++++++++++++++++ mail_compose_select_lang/__init__.py | 7 +++ mail_compose_select_lang/__openerp__.py | 22 ++++++++ mail_compose_select_lang/i18n/es.po | 23 ++++++++ .../i18n/mail_compose_select_lang.pot | 23 ++++++++ mail_compose_select_lang/models/__init__.py | 7 +++ .../models/email_template.py | 20 +++++++ mail_compose_select_lang/models/report.py | 20 +++++++ .../static/description/icon.png | Bin 0 -> 1693 bytes mail_compose_select_lang/wizard/__init__.py | 6 +++ .../wizard/mail_compose_message.py | 25 +++++++++ .../wizard/mail_compose_message_view.xml | 23 ++++++++ 12 files changed, 226 insertions(+) create mode 100644 mail_compose_select_lang/README.rst create mode 100644 mail_compose_select_lang/__init__.py create mode 100644 mail_compose_select_lang/__openerp__.py create mode 100644 mail_compose_select_lang/i18n/es.po create mode 100644 mail_compose_select_lang/i18n/mail_compose_select_lang.pot create mode 100644 mail_compose_select_lang/models/__init__.py create mode 100644 mail_compose_select_lang/models/email_template.py create mode 100644 mail_compose_select_lang/models/report.py create mode 100644 mail_compose_select_lang/static/description/icon.png create mode 100644 mail_compose_select_lang/wizard/__init__.py create mode 100644 mail_compose_select_lang/wizard/mail_compose_message.py create mode 100644 mail_compose_select_lang/wizard/mail_compose_message_view.xml diff --git a/mail_compose_select_lang/README.rst b/mail_compose_select_lang/README.rst new file mode 100644 index 00000000..c36740ac --- /dev/null +++ b/mail_compose_select_lang/README.rst @@ -0,0 +1,50 @@ +Select language in mail compose window +====================================== + +This module allows to select the language for the mail content directly in +the mail compose window. + +It also translates attachments that can be linked to the email template. + +Usage +===== + +By default, mail compose window will use corresponding language for showing the +contents, but you will be able to select another language from the dropdown +box "Force language" in the bottom right part. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + +Credits +======= + +Contributors +------------ + +* Pedro M. Baeza + +Icon +---- + +* Original icons from Odoo source code. + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/mail_compose_select_lang/__init__.py b/mail_compose_select_lang/__init__.py new file mode 100644 index 00000000..daf0bbc1 --- /dev/null +++ b/mail_compose_select_lang/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +############################################################################## +# (c) 2015 Pedro M. Baeza +# License AGPL-3 - See LICENSE file on root folder for details +############################################################################## +from . import models +from . import wizard diff --git a/mail_compose_select_lang/__openerp__.py b/mail_compose_select_lang/__openerp__.py new file mode 100644 index 00000000..501d9652 --- /dev/null +++ b/mail_compose_select_lang/__openerp__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# (c) 2015 Pedro M. Baeza +# License AGPL-3 - See LICENSE file on root folder for details +############################################################################## + +{ + 'name': 'Select language in mail compose window', + 'version': '1.0', + 'category': 'Marketing', + 'author': 'Serv. Tecnol. Avanzados - Pedro M. Baeza, ' + 'Antiun IngenierĂ­a S.L.,' + 'Odoo Community Association (OCA)', + 'website': 'http://www.serviciosbaeza.com', + 'depends': [ + 'email_template', + ], + 'data': [ + 'wizard/mail_compose_message_view.xml', + ], + "installable": True, +} diff --git a/mail_compose_select_lang/i18n/es.po b/mail_compose_select_lang/i18n/es.po new file mode 100644 index 00000000..425e3110 --- /dev/null +++ b/mail_compose_select_lang/i18n/es.po @@ -0,0 +1,23 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_compose_select_lang +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-04-02 16:47+0000\n" +"PO-Revision-Date: 2015-04-02 16:47+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mail_compose_select_lang +#: view:mail.compose.message:mail_compose_select_lang.email_compose_message_wizard_inherit_form_lang +#: field:mail.compose.message,lang:0 +msgid "Force language" +msgstr "Forzar idioma" + diff --git a/mail_compose_select_lang/i18n/mail_compose_select_lang.pot b/mail_compose_select_lang/i18n/mail_compose_select_lang.pot new file mode 100644 index 00000000..14e4ecae --- /dev/null +++ b/mail_compose_select_lang/i18n/mail_compose_select_lang.pot @@ -0,0 +1,23 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_compose_select_lang +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-04-02 16:47+0000\n" +"PO-Revision-Date: 2015-04-02 16:47+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mail_compose_select_lang +#: view:mail.compose.message:mail_compose_select_lang.email_compose_message_wizard_inherit_form_lang +#: field:mail.compose.message,lang:0 +msgid "Force language" +msgstr "" + diff --git a/mail_compose_select_lang/models/__init__.py b/mail_compose_select_lang/models/__init__.py new file mode 100644 index 00000000..208bd250 --- /dev/null +++ b/mail_compose_select_lang/models/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +############################################################################## +# (c) 2015 Pedro M. Baeza +# License AGPL-3 - See LICENSE file on root folder for details +############################################################################## +from . import email_template +from . import report diff --git a/mail_compose_select_lang/models/email_template.py b/mail_compose_select_lang/models/email_template.py new file mode 100644 index 00000000..9c349675 --- /dev/null +++ b/mail_compose_select_lang/models/email_template.py @@ -0,0 +1,20 @@ +# -*- 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) diff --git a/mail_compose_select_lang/models/report.py b/mail_compose_select_lang/models/report.py new file mode 100644 index 00000000..8e200a5b --- /dev/null +++ b/mail_compose_select_lang/models/report.py @@ -0,0 +1,20 @@ +# -*- 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) diff --git a/mail_compose_select_lang/static/description/icon.png b/mail_compose_select_lang/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..8d59759b8db91884f0e7620a50029730e28fd355 GIT binary patch literal 1693 zcmV;O24eY%P)HzQti7$*P#1}aHJ zK~!ko?U_q#8`l+vzj=|RB$wn2ha3u$T>+9B1fXje1%ehSS~yN?p$NK478aUrRKRGP zRTe3d28R1W(@nPqYP7Z6cu_ACG>&D#u+@Yonq%5@#XV`H@0Hl^>@%z!Muq#+pO zcgK&v03ZdFP1%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