[17.0][MIG] mail_attach_existing_attachment: pre-commit

pull/1292/head
andrea 2024-02-03 12:47:38 +01:00
parent 4f9792a782
commit 56addab119
13 changed files with 98 additions and 77 deletions

View File

@ -17,19 +17,20 @@ Mail Attach Existing Attachment
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
:target: https://github.com/OCA/social/tree/16.0/mail_attach_existing_attachment
:target: https://github.com/OCA/social/tree/17.0/mail_attach_existing_attachment
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_attach_existing_attachment
:target: https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_attach_existing_attachment
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=17.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
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
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
**Table of contents**
@ -41,20 +42,23 @@ Usage
To use this module, you need to:
* Add some attachments on an object by creating a new *Log note*
- Add some attachments on an object by creating a new *Log note*
.. figure:: https://raw.githubusercontent.com/OCA/social/16.0/mail_attach_existing_attachment/static/description/attachment.png
:alt: Attachment on purchase order
|image1|
* Then, by sending the object via email, you can select the attachment added earlier
- Then, by sending the object via email, you can select the attachment
added earlier
.. figure:: https://raw.githubusercontent.com/OCA/social/16.0/mail_attach_existing_attachment/static/description/ex_mail_compose_message.png
:alt: Sends the Purchase Order by email
|image2|
.. |image1| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_attach_existing_attachment/static/description/attachment.png
.. |image2| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_attach_existing_attachment/static/description/ex_mail_compose_message.png
Known issues / Roadmap
======================
* The module only allows the addition of attachments linked to the object.
- The module only allows the addition of attachments linked to the
object.
Bug Tracker
===========
@ -62,7 +66,7 @@ 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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_attach_existing_attachment%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_attach_existing_attachment%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@ -70,23 +74,27 @@ Credits
=======
Authors
~~~~~~~
-------
* ACSONE SA/NV
* Tecnativa
Contributors
~~~~~~~~~~~~
------------
* Adrien Peiffer <adrien.peiffer@acsone.eu>
* Benoit Aimont <benoit.aimont@acsone.eu>
* `Tecnativa <https://www.tecnativa.com>`_:
- Adrien Peiffer <adrien.peiffer@acsone.eu>
- Benoit Aimont <benoit.aimont@acsone.eu>
- `Tecnativa <https://www.tecnativa.com>`__:
* Sergio Teruel
* Ernesto Tejeda
- Sergio Teruel
- Ernesto Tejeda
- `360ERP <https://www.360erp.com>`__:
- Andrea Stirpe
Maintainers
~~~~~~~~~~~
-----------
This module is maintained by the OCA.
@ -98,6 +106,6 @@ 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.
This module is part of the `OCA/social <https://github.com/OCA/social/tree/16.0/mail_attach_existing_attachment>`_ project on GitHub.
This module is part of the `OCA/social <https://github.com/OCA/social/tree/17.0/mail_attach_existing_attachment>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"

View File

@ -0,0 +1,7 @@
- Adrien Peiffer \<<adrien.peiffer@acsone.eu>\>
- Benoit Aimont \<<benoit.aimont@acsone.eu>\>
- [Tecnativa](https://www.tecnativa.com):
- Sergio Teruel
- Ernesto Tejeda
- [360ERP](https://www.360erp.com):
- Andrea Stirpe

View File

@ -1,10 +0,0 @@
* Adrien Peiffer <adrien.peiffer@acsone.eu>
* Benoit Aimont <benoit.aimont@acsone.eu>
* `Tecnativa <https://www.tecnativa.com>`_:
* Sergio Teruel
* Ernesto Tejeda
* `360ERP <https://www.360erp.com>`_:
* Andrea Stirpe

View File

@ -0,0 +1,3 @@
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

View File

@ -1,2 +0,0 @@
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

View File

@ -0,0 +1,2 @@
- The module only allows the addition of attachments linked to the
object.

View File

@ -1 +0,0 @@
* The module only allows the addition of attachments linked to the object.

View File

@ -0,0 +1,10 @@
To use this module, you need to:
- Add some attachments on an object by creating a new *Log note*
![](../static/description/attachment.png)
- Then, by sending the object via email, you can select the attachment
added earlier
![](../static/description/ex_mail_compose_message.png)

View File

@ -1,11 +0,0 @@
To use this module, you need to:
* Add some attachments on an object by creating a new *Log note*
.. 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

View File

@ -368,9 +368,10 @@ ul.auto-toc {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ac2a9aa40b0d4a582c625061abbe71035a0b6c6421af29465d20d9e51dcfbda3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/social/tree/16.0/mail_attach_existing_attachment"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_attach_existing_attachment"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/social&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>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</p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/social/tree/17.0/mail_attach_existing_attachment"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_attach_existing_attachment"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/social&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>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</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
@ -391,20 +392,18 @@ the object by sending it by email with the mail compose message wizard</p>
<ul class="simple">
<li>Add some attachments on an object by creating a new <em>Log note</em></li>
</ul>
<div class="figure">
<img alt="Attachment on purchase order" src="https://raw.githubusercontent.com/OCA/social/16.0/mail_attach_existing_attachment/static/description/attachment.png" />
</div>
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/social/17.0/mail_attach_existing_attachment/static/description/attachment.png" /></p>
<ul class="simple">
<li>Then, by sending the object via email, you can select the attachment added earlier</li>
<li>Then, by sending the object via email, you can select the attachment
added earlier</li>
</ul>
<div class="figure">
<img alt="Sends the Purchase Order by email" src="https://raw.githubusercontent.com/OCA/social/16.0/mail_attach_existing_attachment/static/description/ex_mail_compose_message.png" />
</div>
<p><img alt="image2" src="https://raw.githubusercontent.com/OCA/social/17.0/mail_attach_existing_attachment/static/description/ex_mail_compose_message.png" /></p>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>The module only allows the addition of attachments linked to the object.</li>
<li>The module only allows the addition of attachments linked to the
object.</li>
</ul>
</div>
<div class="section" id="bug-tracker">
@ -412,7 +411,7 @@ the object by sending it by email with the mail compose message wizard</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_attach_existing_attachment%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_attach_existing_attachment%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -434,6 +433,10 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<li>Ernesto Tejeda</li>
</ul>
</li>
<li><a class="reference external" href="https://www.360erp.com">360ERP</a>:<ul>
<li>Andrea Stirpe</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
@ -443,7 +446,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/16.0/mail_attach_existing_attachment">OCA/social</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/17.0/mail_attach_existing_attachment">OCA/social</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -6,10 +6,9 @@ from odoo.tests.common import Form, TransactionCase
class TestMailComposer(TransactionCase):
@classmethod
def setUpClass(cls):
super(TestMailComposer, cls).setUpClass()
super().setUpClass()
cls.partner_01 = cls.env["res.partner"].create(
{
"name": "Partner 1",
@ -30,11 +29,13 @@ class TestMailComposer(TransactionCase):
def test_01_send_email_attachment(self):
"""Test sending amail with attachment from Object Attachment of composer"""
# Open email composer
composer_form = Form(self.env['mail.compose.message'].with_context({
'default_composition_mode': 'comment',
'default_model': self.partner_01._name,
'default_res_ids': self.partner_01.ids,
}))
composer_form = Form(
self.env["mail.compose.message"].with_context(
default_composition_mode="comment",
default_model=self.partner_01._name,
default_res_ids=self.partner_01.ids,
)
)
# Field can_attach_attachment is automatically set
self.assertTrue(composer_form.can_attach_attachment)
@ -63,13 +64,19 @@ class TestMailComposer(TransactionCase):
"""Test method _prepare_mail_values()"""
attach2 = self.attach1.copy()
# Create email composer with 2 Object Attachments
composer = self.env['mail.compose.message'].with_context({
'default_composition_mode': 'comment',
'default_model': self.partner_01._name,
'default_res_ids': self.partner_01.ids,
}).create({
"object_attachment_ids": (self.attach1 + attach2).ids,
})
composer = (
self.env["mail.compose.message"]
.with_context(
default_composition_mode="comment",
default_model=self.partner_01._name,
default_res_ids=self.partner_01.ids,
)
.create(
{
"object_attachment_ids": (self.attach1 + attach2).ids,
}
)
)
# Two selectable Object Attachments are displayed
display_records = composer.display_object_attachment_ids

View File

@ -38,10 +38,12 @@ class MailComposeMessage(models.TransientModel):
res_ids = self._evaluate_res_ids()
model = self.model
if model and res_ids:
attachments = self.env["ir.attachment"].search([
("res_model", "=", model),
("res_id", "in", res_ids),
])
attachments = self.env["ir.attachment"].search(
[
("res_model", "=", model),
("res_id", "in", res_ids),
]
)
composer.display_object_attachment_ids = attachments
else:
composer.display_object_attachment_ids = False