diff --git a/mail_attach_existing_attachment_account/README.rst b/mail_attach_existing_attachment_account/README.rst new file mode 100644 index 0000000000..d0ee9282ba --- /dev/null +++ b/mail_attach_existing_attachment_account/README.rst @@ -0,0 +1,82 @@ +========================================= +Mail Attach Existing Attachment (Account) +========================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a6718ee50525c347da218d4c3e0b8ab391a2fd2bfaff89a8ce300f40f206be3c + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/17.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-17-0/social-17-0-mail_attach_existing_attachment_account + :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=17.0 + :alt: Try me on Runboat + +|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 to smash 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 + - Ernesto Tejeda + +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 0000000000..78695683c9 --- /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 0000000000..46ac674117 --- /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": "17.0.1.0.0", + "license": "AGPL-3", + "depends": ["account", "mail_attach_existing_attachment"], + "data": ["wizard/account_move_send_view.xml"], + "installable": True, + "auto_install": True, +} diff --git a/mail_attach_existing_attachment_account/i18n/it.po b/mail_attach_existing_attachment_account/i18n/it.po new file mode 100644 index 0000000000..024ab3d36f --- /dev/null +++ b/mail_attach_existing_attachment_account/i18n/it.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_attach_existing_attachment_account +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-12-19 10:06+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.6.2\n" + +#. module: mail_attach_existing_attachment_account +#: model:ir.model,name:mail_attach_existing_attachment_account.model_account_invoice_send +msgid "Account Invoice Send" +msgstr "Conto invio fattura" + +#. module: mail_attach_existing_attachment_account +#: model:ir.model.fields,field_description:mail_attach_existing_attachment_account.field_account_invoice_send__can_attach_attachment +msgid "Can Attach Attachment" +msgstr "Può inserire allegati" 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 0000000000..00c5bfcd19 --- /dev/null +++ b/mail_attach_existing_attachment_account/i18n/mail_attach_existing_attachment_account.pot @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_attach_existing_attachment_account +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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" + +#. module: mail_attach_existing_attachment_account +#: model:ir.model,name:mail_attach_existing_attachment_account.model_account_invoice_send +msgid "Account Invoice Send" +msgstr "" + +#. module: mail_attach_existing_attachment_account +#: model:ir.model.fields,field_description:mail_attach_existing_attachment_account.field_account_invoice_send__can_attach_attachment +msgid "Can Attach Attachment" +msgstr "" diff --git a/mail_attach_existing_attachment_account/pyproject.toml b/mail_attach_existing_attachment_account/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/mail_attach_existing_attachment_account/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/mail_attach_existing_attachment_account/readme/CONTRIBUTORS.md b/mail_attach_existing_attachment_account/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..d06ddae76b --- /dev/null +++ b/mail_attach_existing_attachment_account/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Thore Baden \ +- [Tecnativa](https://www.tecnativa.com): + - Víctor Martínez + - Ernesto Tejeda diff --git a/mail_attach_existing_attachment_account/readme/DESCRIPTION.md b/mail_attach_existing_attachment_account/readme/DESCRIPTION.md new file mode 100644 index 0000000000..6fb430e405 --- /dev/null +++ b/mail_attach_existing_attachment_account/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +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 0000000000..3a0328b516 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 0000000000..9b076ce799 --- /dev/null +++ b/mail_attach_existing_attachment_account/static/description/index.html @@ -0,0 +1,427 @@ + + + + + +Mail Attach Existing Attachment (Account) + + + +
+

Mail Attach Existing Attachment (Account)

+ + +

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

+

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 to smash 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 0000000000..277c7fbde3 --- /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 0000000000..ef110542bb --- /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.TransactionCase): + @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_move_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.move.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 0000000000..cf39f38e70 --- /dev/null +++ b/mail_attach_existing_attachment_account/wizard/__init__.py @@ -0,0 +1 @@ +from . import account_move_send diff --git a/mail_attach_existing_attachment_account/wizard/account_move_send.py b/mail_attach_existing_attachment_account/wizard/account_move_send.py new file mode 100644 index 0000000000..31e6aa5991 --- /dev/null +++ b/mail_attach_existing_attachment_account/wizard/account_move_send.py @@ -0,0 +1,62 @@ +# 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 AccountMoveSend(models.TransientModel): + _inherit = "account.move.send" + + can_attach_attachment = fields.Boolean() + object_attachment_ids = fields.Many2many( + comodel_name="ir.attachment", + relation="account_move_send_ir_attachments_object_rel", + column1="wizard_id", + column2="attachment_id", + string="Object Attachments", + ) + display_object_attachment_ids = fields.One2many( + comodel_name="ir.attachment", + compute="_compute_display_object_attachment_ids", + ) + + @api.depends("move_ids") + def _compute_display_object_attachment_ids(self): + for wizard in self: + if self.move_ids: + attachments = self.env["ir.attachment"].search( + [ + ("res_model", "=", "account.move"), + ("res_id", "in", self.move_ids.ids), + ] + ) + wizard.display_object_attachment_ids = attachments + else: + wizard.display_object_attachment_ids = False + + # def _prepare_mail_values(self, res_ids): + # res = super()._prepare_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 + + @api.model + def _get_invoice_extra_attachments(self, move): + res = super()._get_invoice_extra_attachments(move) + res |= self.object_attachment_ids + return res + + @api.model + def default_get(self, fields_list): + res = super().default_get(fields_list) + if ( + res.get("move_ids") + and res.get("mode", "") != "invoice_multi" + and not res.get("can_attach_attachment") + ): + res["can_attach_attachment"] = True # pragma: no cover + return res + + can_attach_attachment = fields.Boolean() diff --git a/mail_attach_existing_attachment_account/wizard/account_move_send_view.xml b/mail_attach_existing_attachment_account/wizard/account_move_send_view.xml new file mode 100644 index 0000000000..a4707cb240 --- /dev/null +++ b/mail_attach_existing_attachment_account/wizard/account_move_send_view.xml @@ -0,0 +1,23 @@ + + + + + Send Invoice + account.move.send + + + + + + + + +