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 00000000..8d59759b Binary files /dev/null and b/mail_compose_select_lang/static/description/icon.png differ diff --git a/mail_compose_select_lang/wizard/__init__.py b/mail_compose_select_lang/wizard/__init__.py new file mode 100644 index 00000000..fe9f9ab9 --- /dev/null +++ b/mail_compose_select_lang/wizard/__init__.py @@ -0,0 +1,6 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# (c) 2015 Pedro M. Baeza +# License AGPL-3 - See LICENSE file on root folder for details +############################################################################## +from . import mail_compose_message diff --git a/mail_compose_select_lang/wizard/mail_compose_message.py b/mail_compose_select_lang/wizard/mail_compose_message.py new file mode 100644 index 00000000..acfa7f6f --- /dev/null +++ b/mail_compose_select_lang/wizard/mail_compose_message.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# (c) 2015 Pedro M. Baeza +# License AGPL-3 - See LICENSE file on root folder for details +############################################################################## +from openerp import models, fields, api + + +class MailComposeMessage(models.TransientModel): + _inherit = 'mail.compose.message' + + lang = fields.Many2one( + comodel_name="res.lang", string="Force language") + + @api.multi + def onchange_lang( + self, lang, template_id, composition_mode, model, res_id): + res = {} + if lang: + lang = self.env['res.lang'].browse(lang) + obj = self.with_context(force_lang=lang.code) + res = obj.onchange_template_id( + composition_mode=composition_mode, model=model, + template_id=template_id, res_id=res_id) + return res diff --git a/mail_compose_select_lang/wizard/mail_compose_message_view.xml b/mail_compose_select_lang/wizard/mail_compose_message_view.xml new file mode 100644 index 00000000..e4a7476c --- /dev/null +++ b/mail_compose_select_lang/wizard/mail_compose_message_view.xml @@ -0,0 +1,23 @@ + + + + + + mail.compose.message.form.lang + mail.compose.message + + + +
Force language + +
+
+
+
+ +
+