Browse Source

[MIG][9.0] mail_attach_existing_attachment: Module migrated (#68)

* [MIG][9.0] mail_attach_existing_attachment: Module migrated
pull/317/head
Sergio Teruel Albert 8 years ago
committed by Pedro M. Baeza
parent
commit
937ea45db4
  1. 13
      mail_attach_existing_attachment/README.rst
  2. 7
      mail_attach_existing_attachment/__openerp__.py
  3. BIN
      mail_attach_existing_attachment/static/description/icon.png
  4. 2
      mail_attach_existing_attachment/tests/test_mail_attach_existing_attachment.py
  5. 18
      mail_attach_existing_attachment/wizard/mail_compose_message.py

13
mail_attach_existing_attachment/README.rst

@ -31,7 +31,7 @@ To configure this module, you need to:
.. 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
:target: https://runbot.odoo-community.org/runbot/205/9.0
Known issues / Roadmap
======================
@ -41,10 +41,10 @@ Known issues / Roadmap
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**>`_.
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.
Credits
=======
@ -53,6 +53,7 @@ Contributors
------------
* Adrien Peiffer <adrien.peiffer@acsone.eu>
* Sergio Teruel <sergio.teruel@tecnativa.com>
Maintainer
----------
@ -65,4 +66,4 @@ 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.
To contribute to this module, please visit http://odoo-community.org.

7
mail_attach_existing_attachment/__openerp__.py

@ -26,10 +26,12 @@
'name': "Mail Attach Existing Attachment",
'summary': """
Adding attachment on the object by sending this one""",
'author': "ACSONE SA/NV,Odoo Community Association (OCA)",
'author': "ACSONE SA/NV,"
"Tecnativa,"
"Odoo Community Association (OCA)",
'website': "http://acsone.eu",
'category': 'Social Network',
'version': '8.0.1.0.0',
'version': '9.0.1.0.0',
'license': 'AGPL-3',
'depends': [
'mail',
@ -38,4 +40,5 @@
'data': [
'wizard/mail_compose_message_view.xml',
],
'installable': True,
}

BIN
mail_attach_existing_attachment/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 4.7 KiB

2
mail_attach_existing_attachment/tests/test_mail_attach_existing_attachment.py

@ -44,6 +44,6 @@ class TestAttachExistingAttachment(common.TransactionCase):
'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])
values = mail.get_mail_values([self.partner_01.id])
self.assertTrue(attach1.id in
values[self.partner_01.id]['attachment_ids'])

18
mail_attach_existing_attachment/wizard/mail_compose_message.py

@ -35,7 +35,7 @@ class MailComposeMessage(models.TransientModel):
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
res['can_attach_attachment'] = True # pragma: no cover
return res
can_attach_attachment = fields.Boolean(string='Can Attach Attachment')
@ -44,14 +44,10 @@ class MailComposeMessage(models.TransientModel):
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)
@api.multi
def get_mail_values(self, res_ids):
res = super(MailComposeMessage, self).get_mail_values(res_ids)
if self.object_attachment_ids.ids and self.model and len(res_ids) == 1:
res[res_ids[0]].setdefault('attachment_ids', []).extend(
self.object_attachment_ids.ids)
return res
Loading…
Cancel
Save