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 index 56b19aeb0..61e01fe6b 100644 --- a/mail_attach_existing_attachment/tests/test_mail_attach_existing_attachment.py +++ b/mail_attach_existing_attachment/tests/test_mail_attach_existing_attachment.py @@ -1,7 +1,7 @@ # Copyright 2015 ACSONE SA/NV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo.tests import common +from odoo.tests import Form, common class TestAttachExistingAttachment(common.TransactionCase): @@ -35,3 +35,11 @@ class TestAttachExistingAttachment(common.TransactionCase): mail = self.env["mail.compose.message"].create(vals) values = mail.get_mail_values([self.partner_01.id]) self.assertTrue(attach1.id in values[self.partner_01.id]["attachment_ids"]) + + def test_wizard(self): + compose = Form( + self.env["mail.compose.message"].with_context( + default_res_id=self.partner_01.id, default_model=self.partner_obj._name, + ) + ) + self.assertTrue(compose.can_attach_attachment) diff --git a/mail_attach_existing_attachment_account/README.rst b/mail_attach_existing_attachment_account/README.rst new file mode 100644 index 000000000..8b27d4298 --- /dev/null +++ b/mail_attach_existing_attachment_account/README.rst @@ -0,0 +1,78 @@ +========================================= +Mail Attach Existing Attachment (Account) +========================================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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/13.0/mail_attach_existing_attachment_account + :alt: OCA/social +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/social-13-0/social-13-0-mail_attach_existing_attachment_account + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/205/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This Module adds the mail_attach_existing_attachment feature to the account module, +since there is a change in odoo 12.0, which adds a new mail wizard form to the account module + +**Table of contents** + +.. contents:: + :local: + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Thore Baden + +Contributors +~~~~~~~~~~~~ + +* Thore Baden + +* `Tecnativa `_: + + * Víctor Martínez + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_attach_existing_attachment_account/__init__.py b/mail_attach_existing_attachment_account/__init__.py new file mode 100644 index 000000000..78695683c --- /dev/null +++ b/mail_attach_existing_attachment_account/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import wizard diff --git a/mail_attach_existing_attachment_account/__manifest__.py b/mail_attach_existing_attachment_account/__manifest__.py new file mode 100644 index 000000000..9beadade7 --- /dev/null +++ b/mail_attach_existing_attachment_account/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2019 Thore Baden +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Mail Attach Existing Attachment (Account)", + "summary": "Module to use attach existing attachment for account module", + "author": "Thore Baden, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/social", + "category": "Social Network", + "version": "13.0.1.0.0", + "license": "AGPL-3", + "depends": ["account", "mail_attach_existing_attachment"], + "data": ["wizard/account_invoice_send_view.xml"], + "installable": True, + "auto_install": True, +} diff --git a/mail_attach_existing_attachment_account/i18n/mail_attach_existing_attachment_account.pot b/mail_attach_existing_attachment_account/i18n/mail_attach_existing_attachment_account.pot new file mode 100644 index 000000000..d2e396f15 --- /dev/null +++ b/mail_attach_existing_attachment_account/i18n/mail_attach_existing_attachment_account.pot @@ -0,0 +1,14 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + diff --git a/mail_attach_existing_attachment_account/readme/CONTRIBUTORS.rst b/mail_attach_existing_attachment_account/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..f4dc58cce --- /dev/null +++ b/mail_attach_existing_attachment_account/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* Thore Baden + +* `Tecnativa `_: + + * Víctor Martínez diff --git a/mail_attach_existing_attachment_account/readme/DESCRIPTION.rst b/mail_attach_existing_attachment_account/readme/DESCRIPTION.rst new file mode 100644 index 000000000..03b832e46 --- /dev/null +++ b/mail_attach_existing_attachment_account/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This Module adds the mail_attach_existing_attachment feature to the account module, +since there is a change in odoo 12.0, which adds a new mail wizard form to the account module diff --git a/mail_attach_existing_attachment_account/static/description/icon.png b/mail_attach_existing_attachment_account/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/mail_attach_existing_attachment_account/static/description/icon.png differ diff --git a/mail_attach_existing_attachment_account/static/description/index.html b/mail_attach_existing_attachment_account/static/description/index.html new file mode 100644 index 000000000..77c1c7b70 --- /dev/null +++ b/mail_attach_existing_attachment_account/static/description/index.html @@ -0,0 +1,424 @@ + + + + + + +Mail Attach Existing Attachment (Account) + + + +
+

Mail Attach Existing Attachment (Account)

+ + +

Beta License: AGPL-3 OCA/social Translate me on Weblate Try me on Runbot

+

This Module adds the mail_attach_existing_attachment feature to the account module, +since there is a change in odoo 12.0, which adds a new mail wizard form to the account module

+

Table of contents

+ +
+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Thore Baden
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/mail_attach_existing_attachment_account/tests/__init__.py b/mail_attach_existing_attachment_account/tests/__init__.py new file mode 100644 index 000000000..277c7fbde --- /dev/null +++ b/mail_attach_existing_attachment_account/tests/__init__.py @@ -0,0 +1 @@ +from . import test_mail_attach_existing_attachment_account diff --git a/mail_attach_existing_attachment_account/tests/test_mail_attach_existing_attachment_account.py b/mail_attach_existing_attachment_account/tests/test_mail_attach_existing_attachment_account.py new file mode 100644 index 000000000..bdee88e89 --- /dev/null +++ b/mail_attach_existing_attachment_account/tests/test_mail_attach_existing_attachment_account.py @@ -0,0 +1,33 @@ +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.tests import Form, common + + +class TestMailAttachExistingAttachmentAccount(common.SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.product = cls.env["product.product"].create({"name": "Test product"}) + cls.partner = cls.env["res.partner"].create({"name": "Mr. Odoo"}) + cls.journal = cls.env["account.journal"].create( + {"name": "Test sale journal", "code": "TSALE", "type": "sale"} + ) + invoice_form = Form( + cls.env["account.move"].with_context(default_type="out_invoice") + ) + invoice_form.partner_id = cls.partner + with invoice_form.invoice_line_ids.new() as line_form: + line_form.product_id = cls.product + cls.invoice = invoice_form.save() + cls.invoice.action_post() + + def test_account_invoice_send(self): + compose = Form( + self.env["account.invoice.send"].with_context( + active_ids=self.invoice.ids, + default_model=self.invoice._name, + default_res_id=self.invoice.id, + default_res_model=self.invoice._name, + ) + ) + self.assertTrue(compose.can_attach_attachment) diff --git a/mail_attach_existing_attachment_account/wizard/__init__.py b/mail_attach_existing_attachment_account/wizard/__init__.py new file mode 100644 index 000000000..edaf0442f --- /dev/null +++ b/mail_attach_existing_attachment_account/wizard/__init__.py @@ -0,0 +1 @@ +from . import account_invoice_send diff --git a/mail_attach_existing_attachment_account/wizard/account_invoice_send.py b/mail_attach_existing_attachment_account/wizard/account_invoice_send.py new file mode 100644 index 000000000..e6603e352 --- /dev/null +++ b/mail_attach_existing_attachment_account/wizard/account_invoice_send.py @@ -0,0 +1,22 @@ +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class AccountInvoiceSend(models.TransientModel): + _inherit = "account.invoice.send" + + @api.model + def default_get(self, fields_list): + res = super().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 # pragma: no cover + return res + + can_attach_attachment = fields.Boolean(string="Can Attach Attachment",) diff --git a/mail_attach_existing_attachment_account/wizard/account_invoice_send_view.xml b/mail_attach_existing_attachment_account/wizard/account_invoice_send_view.xml new file mode 100644 index 000000000..88c19beaa --- /dev/null +++ b/mail_attach_existing_attachment_account/wizard/account_invoice_send_view.xml @@ -0,0 +1,27 @@ + + + + + Send Invoice + account.invoice.send + + + + + + +
+
+ +
+
+
+
+
diff --git a/setup/mail_attach_existing_attachment_account/odoo/addons/mail_attach_existing_attachment_account b/setup/mail_attach_existing_attachment_account/odoo/addons/mail_attach_existing_attachment_account new file mode 120000 index 000000000..2deb5f500 --- /dev/null +++ b/setup/mail_attach_existing_attachment_account/odoo/addons/mail_attach_existing_attachment_account @@ -0,0 +1 @@ +../../../../mail_attach_existing_attachment_account \ No newline at end of file diff --git a/setup/mail_attach_existing_attachment_account/setup.py b/setup/mail_attach_existing_attachment_account/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/mail_attach_existing_attachment_account/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)