diff --git a/mail_attach_existing_attachment/README.rst b/mail_attach_existing_attachment/README.rst new file mode 100644 index 0000000..50784be --- /dev/null +++ b/mail_attach_existing_attachment/README.rst @@ -0,0 +1,68 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Mail Attach Existing Attachment +=============================== + +This module was written to add the possibility to add attachments located on +the object by sending it by email with the mail compose message wizard + +Installation +============ + +To install this module, you need to: + +* Click on install + +Usage +===== + +To configure this module, you need to: + +* Adding some attachments on an object + +.. figure:: static/description/attachment.png + :alt: Attachment on purchase order + +* Then, by sending the object via email, you can select the attachment added earlier + +.. figure:: static/description/ex_mail_compose_message.png + :alt: Sends the Purchase Order by email + +.. 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/8.0 + +Known issues / Roadmap +====================== + +* The module only allows the addition of attachments linked to the object. + +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 + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://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. \ No newline at end of file diff --git a/mail_attach_existing_attachment/__init__.py b/mail_attach_existing_attachment/__init__.py new file mode 100644 index 0000000..02baef4 --- /dev/null +++ b/mail_attach_existing_attachment/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import wizard diff --git a/mail_attach_existing_attachment/__openerp__.py b/mail_attach_existing_attachment/__openerp__.py new file mode 100644 index 0000000..7ec7bbb --- /dev/null +++ b/mail_attach_existing_attachment/__openerp__.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This file is part of mail_attach_existing_attachment, +# an Odoo module. +# +# Copyright (c) 2015 ACSONE SA/NV () +# +# mail_attach_existing_attachment is free software: +# you can redistribute it and/or modify it under the terms of the GNU +# Affero General Public License as published by the Free Software +# Foundation,either version 3 of the License, or (at your option) any +# later version. +# +# mail_attach_existing_attachment is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with mail_attach_existing_attachment. +# If not, see . +# +############################################################################## +{ + 'name': "Mail Attach Existing Attachment", + 'summary': """ + Adding attachment on the object by sending this one""", + 'author': "ACSONE SA/NV,Odoo Community Association (OCA)", + 'website': "http://acsone.eu", + 'category': 'Social Network', + 'version': '8.0.1.0.0', + 'license': 'AGPL-3', + 'depends': [ + 'mail', + 'document', + ], + 'data': [ + 'wizard/mail_compose_message_view.xml', + ], +} diff --git a/mail_attach_existing_attachment/i18n/pt_BR.po b/mail_attach_existing_attachment/i18n/pt_BR.po new file mode 100644 index 0000000..b74de81 --- /dev/null +++ b/mail_attach_existing_attachment/i18n/pt_BR.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_attach_existing_attachment +# +# Translators: +# Armando Vulcano Junior , 2015 +msgid "" +msgstr "" +"Project-Id-Version: social (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-09-30 16:56+0000\n" +"PO-Revision-Date: 2015-09-18 19:58+0000\n" +"Last-Translator: Armando Vulcano Junior \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_attach_existing_attachment +#: field:mail.compose.message,object_attachment_ids:0 +msgid "Attachments" +msgstr "Anexos" + +#. module: mail_attach_existing_attachment +#: field:mail.compose.message,can_attach_attachment:0 +msgid "Can Attach Attachment" +msgstr "Pode Anexar Anexo" + +#. module: mail_attach_existing_attachment +#: model:ir.model,name:mail_attach_existing_attachment.model_mail_compose_message +msgid "Email composition wizard" +msgstr "Assistente de Composição de Email" diff --git a/mail_attach_existing_attachment/i18n/sl.po b/mail_attach_existing_attachment/i18n/sl.po new file mode 100644 index 0000000..2f00e5d --- /dev/null +++ b/mail_attach_existing_attachment/i18n/sl.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_attach_existing_attachment +# +# Translators: +# Matjaž Mozetič , 2015 +msgid "" +msgstr "" +"Project-Id-Version: social (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-09-04 14:42+0000\n" +"PO-Revision-Date: 2015-09-07 14:25+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_attach_existing_attachment +#: field:mail.compose.message,object_attachment_ids:0 +msgid "Attachments" +msgstr "Priponke" + +#. module: mail_attach_existing_attachment +#: field:mail.compose.message,can_attach_attachment:0 +msgid "Can Attach Attachment" +msgstr "Lahko pripenja priponke" + +#. module: mail_attach_existing_attachment +#: model:ir.model,name:mail_attach_existing_attachment.model_mail_compose_message +msgid "Email composition wizard" +msgstr "Čarovnik za sestavljanje e-pošte" diff --git a/mail_attach_existing_attachment/static/description/attachment.png b/mail_attach_existing_attachment/static/description/attachment.png new file mode 100644 index 0000000..15e101e Binary files /dev/null and b/mail_attach_existing_attachment/static/description/attachment.png differ diff --git a/mail_attach_existing_attachment/static/description/ex_mail_compose_message.png b/mail_attach_existing_attachment/static/description/ex_mail_compose_message.png new file mode 100644 index 0000000..5742434 Binary files /dev/null and b/mail_attach_existing_attachment/static/description/ex_mail_compose_message.png differ diff --git a/mail_attach_existing_attachment/tests/__init__.py b/mail_attach_existing_attachment/tests/__init__.py new file mode 100644 index 0000000..26c2cf0 --- /dev/null +++ b/mail_attach_existing_attachment/tests/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import test_mail_attach_existing_attachment diff --git a/mail_attach_existing_attachment/tests/test_mail_attach_existing_attachment.py b/mail_attach_existing_attachment/tests/test_mail_attach_existing_attachment.py new file mode 100644 index 0000000..eed39bc --- /dev/null +++ b/mail_attach_existing_attachment/tests/test_mail_attach_existing_attachment.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This file is part of mail_attach_existing_attachment, +# an Odoo module. +# +# Copyright (c) 2015 ACSONE SA/NV () +# +# mail_attach_existing_attachment is free software: +# you can redistribute it and/or modify it under the terms of the GNU +# Affero General Public License as published by the Free Software +# Foundation,either version 3 of the License, or (at your option) any +# later version. +# +# mail_attach_existing_attachment is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with mail_attach_existing_attachment. +# If not, see . +# +############################################################################## + +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_1') + + def test_send_email_attachment(self): + attach1 = self.env['ir.attachment'].create({ + 'name': 'Attach1', 'datas_fname': 'Attach1', + 'datas': 'bWlncmF0aW9uIHRlc3Q=', + 'res_model': 'res.partner', 'res_id': self.partner_01.id}) + vals = {'model': 'res.partner', + 'partner_ids': [(6, 0, [self.partner_01.id])], + 'res_id': self.partner_01.id, + 'object_attachment_ids': [(6, 0, [attach1.id])] + } + mail = self.env['mail.compose.message'].create(vals) + values = mail.get_mail_values(mail, [self.partner_01.id]) + self.assertTrue(attach1.id in + values[self.partner_01.id]['attachment_ids']) diff --git a/mail_attach_existing_attachment/wizard/__init__.py b/mail_attach_existing_attachment/wizard/__init__.py new file mode 100644 index 0000000..12ddb2d --- /dev/null +++ b/mail_attach_existing_attachment/wizard/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import mail_compose_message diff --git a/mail_attach_existing_attachment/wizard/mail_compose_message.py b/mail_attach_existing_attachment/wizard/mail_compose_message.py new file mode 100644 index 0000000..4c7d43f --- /dev/null +++ b/mail_attach_existing_attachment/wizard/mail_compose_message.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This file is part of mail_attach_existing_attachment, +# an Odoo module. +# +# Copyright (c) 2015 ACSONE SA/NV () +# +# mail_attach_existing_attachment is free software: +# you can redistribute it and/or modify it under the terms of the GNU +# Affero General Public License as published by the Free Software +# Foundation,either version 3 of the License, or (at your option) any +# later version. +# +# mail_attach_existing_attachment is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with mail_attach_existing_attachment. +# If not, see . +# +############################################################################## + +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) + if res.get('res_id') and res.get('model') and \ + res.get('composition_mode', '') != 'mass_mail' and\ + not res.get('can_attach_attachment'): + res['can_attach_attachment'] = True + return res + + can_attach_attachment = fields.Boolean(string='Can Attach Attachment') + object_attachment_ids = fields.Many2many( + comodel_name='ir.attachment', + relation='mail_compose_message_ir_attachments_object_rel', + column1='wizard_id', column2='attachment_id', string='Attachments') + + @api.model + def get_mail_values(self, wizard, res_ids): + res = super(MailComposeMessage, self).get_mail_values(wizard, res_ids) + if wizard.object_attachment_ids.ids and wizard.model and\ + len(res_ids) == 1: + for res_id in res_ids: + if not res[res_id].get('attachment_ids'): + res[res_id]['attachment_ids'] = [] + res[res_id]['attachment_ids'].extend( + wizard.object_attachment_ids.ids) + return res diff --git a/mail_attach_existing_attachment/wizard/mail_compose_message_view.xml b/mail_attach_existing_attachment/wizard/mail_compose_message_view.xml new file mode 100644 index 0000000..aa10025 --- /dev/null +++ b/mail_attach_existing_attachment/wizard/mail_compose_message_view.xml @@ -0,0 +1,19 @@ + + + + + mail.compose.message.form (mail_attach_existing_attachment) + mail.compose.message + + + + +
+
+ +
+
+
+
+
+
\ No newline at end of file