Browse Source

[IMP][mail_attach_existing_attachment] Change module name

pull/285/head
Adrien Peiffer (ACSONE) 9 years ago
committed by Holger Brunn
parent
commit
4a70cb3e15
  1. 68
      mail_attach_existing_attachment/README.rst
  2. 2
      mail_attach_existing_attachment/__init__.py
  3. 41
      mail_attach_existing_attachment/__openerp__.py
  4. BIN
      mail_attach_existing_attachment/static/description/attachment.png
  5. BIN
      mail_attach_existing_attachment/static/description/ex_mail_compose_message.png
  6. 3
      mail_attach_existing_attachment/tests/__init__.py
  7. 49
      mail_attach_existing_attachment/tests/test_mail_attach_existing_attachment.py
  8. 2
      mail_attach_existing_attachment/wizard/__init__.py
  9. 57
      mail_attach_existing_attachment/wizard/mail_compose_message.py
  10. 19
      mail_attach_existing_attachment/wizard/mail_compose_message_view.xml

68
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 <https://github.com/OCA/social/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/social/issues/new?body=module:%20mail_attach_existing_attachment%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Adrien Peiffer <adrien.peiffer@acsone.eu>
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.

2
mail_attach_existing_attachment/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import wizard

41
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 (<http://acsone.eu>)
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'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',
],
}

BIN
mail_attach_existing_attachment/static/description/attachment.png

After

Width: 308  |  Height: 96  |  Size: 8.3 KiB

BIN
mail_attach_existing_attachment/static/description/ex_mail_compose_message.png

After

Width: 895  |  Height: 561  |  Size: 53 KiB

3
mail_attach_existing_attachment/tests/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import test_mail_attach_existing_attachment

49
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 (<http://acsone.eu>)
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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'])

2
mail_attach_existing_attachment/wizard/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import mail_compose_message

57
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 (<http://acsone.eu>)
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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

19
mail_attach_existing_attachment/wizard/mail_compose_message_view.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<record model="ir.ui.view" id="email_compose_message_wizard_inherit_form">
<field name="name">mail.compose.message.form (mail_attach_existing_attachment)</field>
<field name="model">mail.compose.message</field>
<field name="inherit_id" ref="mail.email_compose_message_wizard_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='attachment_ids']" position="after">
<field name="can_attach_attachment" invisible="1"/>
<div attrs="{'invisible': [('can_attach_attachment', '=', False)]}">
<br />
<field name="object_attachment_ids" widget="many2many_checkboxes" domain="[('res_model', '=', model), ('res_id', '=', res_id)]" />
</div>
</xpath>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save