diff --git a/mail_optional_autofollow/README.rst b/mail_optional_autofollow/README.rst new file mode 100644 index 00000000..7d2cb946 --- /dev/null +++ b/mail_optional_autofollow/README.rst @@ -0,0 +1,55 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +======================== +Mail optional autofollow +======================== + +This module adds the possibility to choose if you want to automatically +add new recipients as followers on mail.compose.message. + +Usage +===== + +To use this module, you need to use the autofollow recipients checkbox on mail.compose.message: + +Technically, this field is initialized to true if there is a +'mail_post_autofollow' key in the current context + +.. figure:: static/description/autofollow.png + :alt: autofollow recipients checkbox + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/205/9.0 + +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 +------------ + +* Adrien Peiffer +* Stéphane Bidoul + +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 https://odoo-community.org. diff --git a/mail_optional_autofollow/__init__.py b/mail_optional_autofollow/__init__.py new file mode 100644 index 00000000..09571272 --- /dev/null +++ b/mail_optional_autofollow/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import wizard diff --git a/mail_optional_autofollow/__openerp__.py b/mail_optional_autofollow/__openerp__.py new file mode 100644 index 00000000..abd3f76b --- /dev/null +++ b/mail_optional_autofollow/__openerp__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + 'name': "Mail optional autofollow", + 'summary': """ + Choose if you want to automatically add new recipients as followers + on mail.compose.message""", + 'author': 'ACSONE SA/NV,' + 'Odoo Community Association (OCA)', + 'website': "http://acsone.eu", + 'category': 'Social Network', + 'version': '9.0.1.0.0', + 'license': 'AGPL-3', + 'depends': [ + 'mail', + ], + 'data': [ + 'wizard/mail_compose_message_view.xml', + ], +} diff --git a/mail_optional_autofollow/i18n/ca.po b/mail_optional_autofollow/i18n/ca.po new file mode 100644 index 00000000..d5748082 --- /dev/null +++ b/mail_optional_autofollow/i18n/ca.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_autofollow +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: social (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-04-14 07:09+0000\n" +"PO-Revision-Date: 2016-04-05 07:05+0000\n" +"Last-Translator: <>\n" +"Language-Team: Catalan (http://www.transifex.com/oca/OCA-social-8-0/language/ca/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: ca\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mail_optional_autofollow +#: model:ir.model,name:mail_optional_autofollow.model_mail_compose_message +msgid "Email composition wizard" +msgstr "Assistent per composició de correus electrònics" + +#. module: mail_optional_autofollow +#: field:mail.compose.message,autofollow_recipients:0 +msgid "Make recipients followers" +msgstr "" + +#. module: mail_optional_autofollow +#: help:mail.compose.message,autofollow_recipients:0 +msgid "" +"if checked, the additional recipients will be added as followers on " +"the related object" +msgstr "" diff --git a/mail_optional_autofollow/i18n/de.po b/mail_optional_autofollow/i18n/de.po new file mode 100644 index 00000000..c2cc1036 --- /dev/null +++ b/mail_optional_autofollow/i18n/de.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_autofollow +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: social (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-04-14 07:09+0000\n" +"PO-Revision-Date: 2016-04-05 07:05+0000\n" +"Last-Translator: <>\n" +"Language-Team: German (http://www.transifex.com/oca/OCA-social-8-0/language/de/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: de\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mail_optional_autofollow +#: model:ir.model,name:mail_optional_autofollow.model_mail_compose_message +msgid "Email composition wizard" +msgstr "Assistent zum Email verfassen" + +#. module: mail_optional_autofollow +#: field:mail.compose.message,autofollow_recipients:0 +msgid "Make recipients followers" +msgstr "" + +#. module: mail_optional_autofollow +#: help:mail.compose.message,autofollow_recipients:0 +msgid "" +"if checked, the additional recipients will be added as followers on " +"the related object" +msgstr "" diff --git a/mail_optional_autofollow/i18n/es.po b/mail_optional_autofollow/i18n/es.po new file mode 100644 index 00000000..dc04d6ad --- /dev/null +++ b/mail_optional_autofollow/i18n/es.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_autofollow +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: social (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-04-14 07:09+0000\n" +"PO-Revision-Date: 2016-04-05 07:05+0000\n" +"Last-Translator: <>\n" +"Language-Team: Spanish (http://www.transifex.com/oca/OCA-social-8-0/language/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mail_optional_autofollow +#: model:ir.model,name:mail_optional_autofollow.model_mail_compose_message +msgid "Email composition wizard" +msgstr "Asistente composición Correo Electrónico" + +#. module: mail_optional_autofollow +#: field:mail.compose.message,autofollow_recipients:0 +msgid "Make recipients followers" +msgstr "" + +#. module: mail_optional_autofollow +#: help:mail.compose.message,autofollow_recipients:0 +msgid "" +"if checked, the additional recipients will be added as followers on " +"the related object" +msgstr "" diff --git a/mail_optional_autofollow/i18n/es_CO.po b/mail_optional_autofollow/i18n/es_CO.po new file mode 100644 index 00000000..0659cee1 --- /dev/null +++ b/mail_optional_autofollow/i18n/es_CO.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_autofollow +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: social (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-04-14 07:09+0000\n" +"PO-Revision-Date: 2016-04-05 07:05+0000\n" +"Last-Translator: <>\n" +"Language-Team: Spanish (Colombia) (http://www.transifex.com/oca/OCA-social-8-0/language/es_CO/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es_CO\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mail_optional_autofollow +#: model:ir.model,name:mail_optional_autofollow.model_mail_compose_message +msgid "Email composition wizard" +msgstr "Asistente de redacción de E-mail" + +#. module: mail_optional_autofollow +#: field:mail.compose.message,autofollow_recipients:0 +msgid "Make recipients followers" +msgstr "" + +#. module: mail_optional_autofollow +#: help:mail.compose.message,autofollow_recipients:0 +msgid "" +"if checked, the additional recipients will be added as followers on " +"the related object" +msgstr "" diff --git a/mail_optional_autofollow/i18n/fr.po b/mail_optional_autofollow/i18n/fr.po new file mode 100644 index 00000000..70fe0208 --- /dev/null +++ b/mail_optional_autofollow/i18n/fr.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_autofollow +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-06-06 12:25+0000\n" +"PO-Revision-Date: 2016-06-06 12:25+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_optional_autofollow +#: model:ir.ui.view,arch_db:mail_optional_autofollow.email_compose_message_wizard_inherit_form +msgid "\n" +"\n" +" \n" +" \n" +" " +msgstr "\n" +"\n" +" \n" +" \n" +" " + +#. module: mail_optional_autofollow +#: model:ir.model,name:mail_optional_autofollow.model_mail_compose_message +msgid "Email composition wizard" +msgstr "Assistant de composition de courriel" + +#. module: mail_optional_autofollow +#: model:ir.model.fields,field_description:mail_optional_autofollow.field_mail_compose_message_autofollow_recipients +#: field:mail.compose.message,autofollow_recipients:0 +msgid "Make recipients followers" +msgstr "Abonner les destinataires" + +#. module: mail_optional_autofollow +#: model:ir.model.fields,help:mail_optional_autofollow.field_mail_compose_message_autofollow_recipients +#: help:mail.compose.message,autofollow_recipients:0 +msgid "if checked, the additional recipients will be added as followers on the related object" +msgstr "Si coché, les destinataires supplémentaires seront ajoutés comme abonné au file de discussion sur l'objet lié" + diff --git a/mail_optional_autofollow/i18n/pt_BR.po b/mail_optional_autofollow/i18n/pt_BR.po new file mode 100644 index 00000000..d72d30b7 --- /dev/null +++ b/mail_optional_autofollow/i18n/pt_BR.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_autofollow +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: social (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-04-14 07:09+0000\n" +"PO-Revision-Date: 2016-04-05 07:05+0000\n" +"Last-Translator: <>\n" +"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-social-8-0/language/pt_BR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: pt_BR\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: mail_optional_autofollow +#: model:ir.model,name:mail_optional_autofollow.model_mail_compose_message +msgid "Email composition wizard" +msgstr "Assistente de Composição de Email" + +#. module: mail_optional_autofollow +#: field:mail.compose.message,autofollow_recipients:0 +msgid "Make recipients followers" +msgstr "" + +#. module: mail_optional_autofollow +#: help:mail.compose.message,autofollow_recipients:0 +msgid "" +"if checked, the additional recipients will be added as followers on " +"the related object" +msgstr "" diff --git a/mail_optional_autofollow/i18n/sl.po b/mail_optional_autofollow/i18n/sl.po new file mode 100644 index 00000000..88e1378b --- /dev/null +++ b/mail_optional_autofollow/i18n/sl.po @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_autofollow +# +# Translators: +# Matjaž Mozetič , 2016 +msgid "" +msgstr "" +"Project-Id-Version: social (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-04-14 07:09+0000\n" +"PO-Revision-Date: 2016-04-06 04:30+0000\n" +"Last-Translator: Matjaž Mozetič \n" +"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-social-8-0/language/sl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: sl\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" + +#. module: mail_optional_autofollow +#: model:ir.model,name:mail_optional_autofollow.model_mail_compose_message +msgid "Email composition wizard" +msgstr "Čarovnik za sestavljanje e-pošte" + +#. module: mail_optional_autofollow +#: field:mail.compose.message,autofollow_recipients:0 +msgid "Make recipients followers" +msgstr "Prejemniki bodo sledilci" + +#. module: mail_optional_autofollow +#: help:mail.compose.message,autofollow_recipients:0 +msgid "" +"if checked, the additional recipients will be added as followers on " +"the related object" +msgstr "če označeno, se objektu dodajo dodatni prejemniki kot sledilci" diff --git a/mail_optional_autofollow/static/description/autofollow.png b/mail_optional_autofollow/static/description/autofollow.png new file mode 100644 index 00000000..ef1aa0f8 Binary files /dev/null and b/mail_optional_autofollow/static/description/autofollow.png differ diff --git a/mail_optional_autofollow/static/description/icon.png b/mail_optional_autofollow/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/mail_optional_autofollow/static/description/icon.png differ diff --git a/mail_optional_autofollow/tests/__init__.py b/mail_optional_autofollow/tests/__init__.py new file mode 100644 index 00000000..3667d24b --- /dev/null +++ b/mail_optional_autofollow/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_mail_optional_autofollow diff --git a/mail_optional_autofollow/tests/test_mail_optional_autofollow.py b/mail_optional_autofollow/tests/test_mail_optional_autofollow.py new file mode 100644 index 00000000..b583af2a --- /dev/null +++ b/mail_optional_autofollow/tests/test_mail_optional_autofollow.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp.tests import common + + +class TestAttachExistingAttachment(common.TransactionCase): + + def setUp(self): + super(TestAttachExistingAttachment, self).setUp() + self.partner_obj = self.env['res.partner'] + self.partner_01 = self.env.ref('base.res_partner_10') + self.partner_02 = self.env.ref('base.res_partner_address_17') + + def test_send_email_attachment(self): + ctx = self.env.context.copy() + ctx.update({ + 'default_model': 'res.partner', + 'default_res_id': self.partner_01.id, + 'default_composition_mode': 'comment', + }) + mail_compose = self.env['mail.compose.message'] + values = mail_compose.with_context(ctx)\ + .onchange_template_id(False, 'comment', 'res.partner', + self.partner_01.id)['value'] + values['partner_ids'] = [(4, self.partner_02.id)] + compose_id = mail_compose.with_context(ctx).create(values) + compose_id.autofollow_recipients = False + compose_id.with_context(ctx).send_mail() + res = self.env["mail.followers"].search( + [('res_model', '=', 'res.partner'), + ('res_id', '=', self.partner_01.id), + ('partner_id', '=', self.partner_02.id)]) + # I check if the recipient isn't a follower + self.assertEqual(len(res.ids), 0) + compose_id = mail_compose.with_context(ctx).create(values) + compose_id.autofollow_recipients = True + compose_id.with_context(ctx).send_mail() + res = self.env["mail.followers"].search( + [('res_model', '=', 'res.partner'), + ('res_id', '=', self.partner_01.id), + ('partner_id', '=', self.partner_02.id)]) + # I check if the recipient is a follower + self.assertEqual(len(res.ids), 1) diff --git a/mail_optional_autofollow/wizard/__init__.py b/mail_optional_autofollow/wizard/__init__.py new file mode 100644 index 00000000..c82500c9 --- /dev/null +++ b/mail_optional_autofollow/wizard/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import mail_compose_message diff --git a/mail_optional_autofollow/wizard/mail_compose_message.py b/mail_optional_autofollow/wizard/mail_compose_message.py new file mode 100644 index 00000000..912a3d91 --- /dev/null +++ b/mail_optional_autofollow/wizard/mail_compose_message.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import models, fields, api + + +class MailComposeMessage(models.TransientModel): + _inherit = 'mail.compose.message' + + @api.model + def default_get(self, fields_list): + res = super(MailComposeMessage, self).default_get(fields_list) + res.setdefault( + 'autofollow_recipients', + self.env.context.get('mail_post_autofollow', False)) + return res + + autofollow_recipients = fields.Boolean( + string='Make recipients followers', + help="""if checked, the additional recipients will be added as\ + followers on the related object""") + + @api.multi + def send_mail(self): + for wizard in self: + super(MailComposeMessage, wizard.with_context( + mail_post_autofollow=wizard.autofollow_recipients)).send_mail() + return {'type': 'ir.actions.act_window_close'} diff --git a/mail_optional_autofollow/wizard/mail_compose_message_view.xml b/mail_optional_autofollow/wizard/mail_compose_message_view.xml new file mode 100644 index 00000000..0bb7eacb --- /dev/null +++ b/mail_optional_autofollow/wizard/mail_compose_message_view.xml @@ -0,0 +1,15 @@ + + + + + mail.compose.message.form (mail_optional_autofollow) + mail.compose.message + + + + + + + + + \ No newline at end of file