Browse Source

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

* [MIG][9.0] mail_attach_existing_attachment: Module migrated
pull/80/head
Sergio Teruel Albert 9 years ago
committed by Pedro M. Baeza
parent
commit
dc8996ebe8
  1. 11
      mail_attach_existing_attachment/README.rst
  2. 8
      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

11
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 .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :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 Known issues / Roadmap
====================== ======================
@ -41,10 +41,10 @@ Known issues / Roadmap
Bug Tracker 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 Credits
======= =======
@ -53,6 +53,7 @@ Contributors
------------ ------------
* Adrien Peiffer <adrien.peiffer@acsone.eu> * Adrien Peiffer <adrien.peiffer@acsone.eu>
* Sergio Teruel <sergio.teruel@tecnativa.com>
Maintainer Maintainer
---------- ----------

8
mail_attach_existing_attachment/__openerp__.py

@ -26,10 +26,12 @@
'name': "Mail Attach Existing Attachment", 'name': "Mail Attach Existing Attachment",
'summary': """ 'summary': """
Adding attachment on the object by sending this one""", 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", 'website': "http://acsone.eu",
'category': 'Social Network', 'category': 'Social Network',
'version': '8.0.1.0.0',
'version': '9.0.1.0.0',
'license': 'AGPL-3', 'license': 'AGPL-3',
'depends': [ 'depends': [
'mail', 'mail',
@ -38,5 +40,5 @@
'data': [ 'data': [
'wizard/mail_compose_message_view.xml', 'wizard/mail_compose_message_view.xml',
], ],
'installable': False,
'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])] 'object_attachment_ids': [(6, 0, [attach1.id])]
} }
mail = self.env['mail.compose.message'].create(vals) 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 self.assertTrue(attach1.id in
values[self.partner_01.id]['attachment_ids']) 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 \ if res.get('res_id') and res.get('model') and \
res.get('composition_mode', '') != 'mass_mail' and\ res.get('composition_mode', '') != 'mass_mail' and\
not res.get('can_attach_attachment'): not res.get('can_attach_attachment'):
res['can_attach_attachment'] = True
res['can_attach_attachment'] = True # pragma: no cover
return res return res
can_attach_attachment = fields.Boolean(string='Can Attach Attachment') 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', relation='mail_compose_message_ir_attachments_object_rel',
column1='wizard_id', column2='attachment_id', string='Attachments') 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 return res
Loading…
Cancel
Save