Browse Source

[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.
pull/2/head
Pedro M. Baeza 10 years ago
parent
commit
b730f58ac4
  1. 50
      mail_compose_select_lang/README.rst
  2. 7
      mail_compose_select_lang/__init__.py
  3. 22
      mail_compose_select_lang/__openerp__.py
  4. 23
      mail_compose_select_lang/i18n/es.po
  5. 23
      mail_compose_select_lang/i18n/mail_compose_select_lang.pot
  6. 7
      mail_compose_select_lang/models/__init__.py
  7. 20
      mail_compose_select_lang/models/email_template.py
  8. 20
      mail_compose_select_lang/models/report.py
  9. BIN
      mail_compose_select_lang/static/description/icon.png
  10. 6
      mail_compose_select_lang/wizard/__init__.py
  11. 25
      mail_compose_select_lang/wizard/mail_compose_message.py
  12. 23
      mail_compose_select_lang/wizard/mail_compose_message_view.xml

50
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 <https://github.com/OCA/server-tools/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 <https://github.com/OCA/server-tools/issues/new?body=module:%20mail_compose_select_lang%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
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.

7
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

22
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,
}

23
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"

23
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 ""

7
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

20
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)

20
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)

BIN
mail_compose_select_lang/static/description/icon.png

After

Width: 48  |  Height: 48  |  Size: 1.7 KiB

6
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

25
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

23
mail_compose_select_lang/wizard/mail_compose_message_view.xml

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="email_compose_message_wizard_inherit_form_lang">
<field name="name">mail.compose.message.form.lang</field>
<field name="model">mail.compose.message</field>
<field name="inherit_id" ref="email_template.email_compose_message_wizard_inherit_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='template_id']/.." position="before">
<div>Force language
<field name="lang"
class="oe_inline"
options="{'no_create': True}"
on_change="onchange_lang(lang, template_id, composition_mode, model, res_id, context)"
/>
</div>
</xpath>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save