diff --git a/mail_composer_cc_bcc_account/README.rst b/mail_composer_cc_bcc_account/README.rst new file mode 100644 index 000000000..2902a6404 --- /dev/null +++ b/mail_composer_cc_bcc_account/README.rst @@ -0,0 +1,116 @@ +===================================== +Email CC and BCC when sending invoice +===================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:dd944995a010180b76d2bfa93b37c70a3866d21822b825cd811895aca5318ff6 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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%2Fmail-lightgray.png?logo=github + :target: https://github.com/OCA/mail/tree/18.0/mail_composer_cc_bcc_account + :alt: OCA/mail +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/mail-18-0/mail-18-0-mail_composer_cc_bcc_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/mail&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to properly separate To:, Cc:, and Bcc: fields in +when sending invoices. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +This module will be automatically installed if both account and +mail_compose_cc_bcc are installed. + +Usage +===== + +Use the cc and bcc fields when sending invoices, to notify other +partners then the invoice contact of the customer. + +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 +------- + +* Camptocamp SA + +Contributors +------------ + +- `Trobz `__: + + - Hai N. Le + - Son Ho + - Tris Doan + +- `Therp BV `__: + + - Ronald Portier + +Other credits +------------- + +The creation and migration of this module from 16.0 to 17.0, and then +17.0 to 18.0 were financially supported by Camptocamp. + +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. + +.. |maintainer-hailangvn2023| image:: https://github.com/hailangvn2023.png?size=40px + :target: https://github.com/hailangvn2023 + :alt: hailangvn2023 + +Current `maintainer `__: + +|maintainer-hailangvn2023| + +This module is part of the `OCA/mail `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_composer_cc_bcc_account/__init__.py b/mail_composer_cc_bcc_account/__init__.py new file mode 100644 index 000000000..c5e1e9785 --- /dev/null +++ b/mail_composer_cc_bcc_account/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2024 Camptocamp +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models +from . import wizards diff --git a/mail_composer_cc_bcc_account/__manifest__.py b/mail_composer_cc_bcc_account/__manifest__.py new file mode 100644 index 000000000..979c20221 --- /dev/null +++ b/mail_composer_cc_bcc_account/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2023 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Email CC and BCC when sending invoice", + "summary": "This module enables sending mail to CC and BCC partners for invoices.", + "version": "18.0.1.0.0", + "development_status": "Alpha", + "category": "Social", + "website": "https://github.com/OCA/mail", + "author": "Camptocamp SA, Odoo Community Association (OCA)", + "maintainers": ["hailangvn2023"], + "license": "AGPL-3", + "application": False, + "installable": True, + "auto_install": True, + "preloadable": True, + "depends": [ + "account", + "mail_composer_cc_bcc", + ], + "data": [ + "wizards/account_move_send_wizard.xml", + ], +} diff --git a/mail_composer_cc_bcc_account/i18n/it.po b/mail_composer_cc_bcc_account/i18n/it.po new file mode 100644 index 000000000..73388557f --- /dev/null +++ b/mail_composer_cc_bcc_account/i18n/it.po @@ -0,0 +1,14 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\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" diff --git a/mail_composer_cc_bcc_account/i18n/mail_composer_cc_bcc_account.pot b/mail_composer_cc_bcc_account/i18n/mail_composer_cc_bcc_account.pot new file mode 100644 index 000000000..6e3f07a0c --- /dev/null +++ b/mail_composer_cc_bcc_account/i18n/mail_composer_cc_bcc_account.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_composer_cc_bcc_account +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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_composer_cc_bcc_account +#: model:ir.model,name:mail_composer_cc_bcc_account.model_account_move_send +msgid "Account Move Send" +msgstr "" + +#. module: mail_composer_cc_bcc_account +#: model:ir.model.fields,field_description:mail_composer_cc_bcc_account.field_account_move_send__partner_bcc_ids +msgid "Bcc" +msgstr "" + +#. module: mail_composer_cc_bcc_account +#: model:ir.model.fields,field_description:mail_composer_cc_bcc_account.field_account_move_send__partner_cc_ids +msgid "Cc" +msgstr "" + +#. module: mail_composer_cc_bcc_account +#: model:ir.model,name:mail_composer_cc_bcc_account.model_mail_thread +msgid "Email Thread" +msgstr "" diff --git a/mail_composer_cc_bcc_account/models/__init__.py b/mail_composer_cc_bcc_account/models/__init__.py new file mode 100644 index 000000000..b70a9f2d0 --- /dev/null +++ b/mail_composer_cc_bcc_account/models/__init__.py @@ -0,0 +1 @@ +from . import mail_thread diff --git a/mail_composer_cc_bcc_account/models/mail_thread.py b/mail_composer_cc_bcc_account/models/mail_thread.py new file mode 100644 index 000000000..c459d1dd5 --- /dev/null +++ b/mail_composer_cc_bcc_account/models/mail_thread.py @@ -0,0 +1,19 @@ +# Copyright 2024 Camptocamp +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class MailThread(models.AbstractModel): + _inherit = "mail.thread" + + def _message_create(self, values_list): + context = self.env.context + res = super()._message_create(values_list) + partners_cc = context.get("partner_cc_ids", None) + if partners_cc: + res.recipient_cc_ids = partners_cc + partners_bcc = context.get("partner_bcc_ids", None) + if partners_bcc: + res.recipient_bcc_ids = partners_bcc + return res diff --git a/mail_composer_cc_bcc_account/pyproject.toml b/mail_composer_cc_bcc_account/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/mail_composer_cc_bcc_account/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/mail_composer_cc_bcc_account/readme/CONFIGURE.md b/mail_composer_cc_bcc_account/readme/CONFIGURE.md new file mode 100644 index 000000000..2ccf27bc9 --- /dev/null +++ b/mail_composer_cc_bcc_account/readme/CONFIGURE.md @@ -0,0 +1 @@ +This module will be automatically installed if both account and mail_compose_cc_bcc are installed. diff --git a/mail_composer_cc_bcc_account/readme/CONTRIBUTORS.md b/mail_composer_cc_bcc_account/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..25b1f000d --- /dev/null +++ b/mail_composer_cc_bcc_account/readme/CONTRIBUTORS.md @@ -0,0 +1,9 @@ +- [Trobz](https://www.trobz.com): + + > - Hai N. Le \<\> + > - Son Ho \<\> + > - Tris Doan \<\> + +- [Therp BV](https://therp.nl): + + > - Ronald Portier \<\> diff --git a/mail_composer_cc_bcc_account/readme/CREDITS.md b/mail_composer_cc_bcc_account/readme/CREDITS.md new file mode 100644 index 000000000..53026c980 --- /dev/null +++ b/mail_composer_cc_bcc_account/readme/CREDITS.md @@ -0,0 +1 @@ +The creation and migration of this module from 16.0 to 17.0, and then 17.0 to 18.0 were financially supported by Camptocamp. diff --git a/mail_composer_cc_bcc_account/readme/DESCRIPTION.md b/mail_composer_cc_bcc_account/readme/DESCRIPTION.md new file mode 100644 index 000000000..750252d96 --- /dev/null +++ b/mail_composer_cc_bcc_account/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module allows to properly separate To:, Cc:, and Bcc: fields in +when sending invoices. diff --git a/mail_composer_cc_bcc_account/readme/USAGE.md b/mail_composer_cc_bcc_account/readme/USAGE.md new file mode 100644 index 000000000..149cff74b --- /dev/null +++ b/mail_composer_cc_bcc_account/readme/USAGE.md @@ -0,0 +1 @@ +Use the cc and bcc fields when sending invoices, to notify other partners then the invoice contact of the customer. diff --git a/mail_composer_cc_bcc_account/static/description/icon.png b/mail_composer_cc_bcc_account/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/mail_composer_cc_bcc_account/static/description/icon.png differ diff --git a/mail_composer_cc_bcc_account/static/description/index.html b/mail_composer_cc_bcc_account/static/description/index.html new file mode 100644 index 000000000..b859ea248 --- /dev/null +++ b/mail_composer_cc_bcc_account/static/description/index.html @@ -0,0 +1,465 @@ + + + + + +Email CC and BCC when sending invoice + + + +
+

Email CC and BCC when sending invoice

+ + +

Alpha License: AGPL-3 OCA/mail Translate me on Weblate Try me on Runboat

+

This module allows to properly separate To:, Cc:, and Bcc: fields in +when sending invoices.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Configuration

+

This module will be automatically installed if both account and +mail_compose_cc_bcc are installed.

+
+
+

Usage

+

Use the cc and bcc fields when sending invoices, to notify other +partners then the invoice contact of the customer.

+
+
+

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

+
    +
  • Camptocamp SA
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The creation and migration of this module from 16.0 to 17.0, and then +17.0 to 18.0 were financially supported by Camptocamp.

+
+
+

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.

+

Current maintainer:

+

hailangvn2023

+

This module is part of the OCA/mail project on GitHub.

+

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

+
+
+
+ + diff --git a/mail_composer_cc_bcc_account/static/img/email_template_form_cc_bcc.png b/mail_composer_cc_bcc_account/static/img/email_template_form_cc_bcc.png new file mode 100644 index 000000000..336e4c1a9 Binary files /dev/null and b/mail_composer_cc_bcc_account/static/img/email_template_form_cc_bcc.png differ diff --git a/mail_composer_cc_bcc_account/static/img/mail_compose_message_default_cc_bcc.png b/mail_composer_cc_bcc_account/static/img/mail_compose_message_default_cc_bcc.png new file mode 100644 index 000000000..7e1b07066 Binary files /dev/null and b/mail_composer_cc_bcc_account/static/img/mail_compose_message_default_cc_bcc.png differ diff --git a/mail_composer_cc_bcc_account/static/img/mail_compose_message_template_cc_bcc.png b/mail_composer_cc_bcc_account/static/img/mail_compose_message_template_cc_bcc.png new file mode 100644 index 000000000..f1de0f5e5 Binary files /dev/null and b/mail_composer_cc_bcc_account/static/img/mail_compose_message_template_cc_bcc.png differ diff --git a/mail_composer_cc_bcc_account/static/img/res_company_form_default_cc_bcc.png b/mail_composer_cc_bcc_account/static/img/res_company_form_default_cc_bcc.png new file mode 100644 index 000000000..8393e3466 Binary files /dev/null and b/mail_composer_cc_bcc_account/static/img/res_company_form_default_cc_bcc.png differ diff --git a/mail_composer_cc_bcc_account/tests/__init__.py b/mail_composer_cc_bcc_account/tests/__init__.py new file mode 100644 index 000000000..7a8ae2177 --- /dev/null +++ b/mail_composer_cc_bcc_account/tests/__init__.py @@ -0,0 +1 @@ +from . import test_mail_cc_bcc diff --git a/mail_composer_cc_bcc_account/tests/test_mail_cc_bcc.py b/mail_composer_cc_bcc_account/tests/test_mail_cc_bcc.py new file mode 100644 index 000000000..22c0ea4b8 --- /dev/null +++ b/mail_composer_cc_bcc_account/tests/test_mail_cc_bcc.py @@ -0,0 +1,41 @@ +# Copyright 2023 Camptocamp +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests import tagged + +from odoo.addons.account.tests.test_account_move_send import TestAccountMoveSendCommon +from odoo.addons.mail.tests.common import MailCommon + + +@tagged("post_install_l10n", "post_install", "-at_install") +class TestMailCcBccInvoice(TestAccountMoveSendCommon, MailCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + env = cls.env + cls.partner = env.ref("base.res_partner_address_31") + cls.partner_cc = env.ref("base.partner_demo") + cls.partner_bcc = env.ref("base.res_partner_main2") + + def test_invoice_mail_cc_bcc(self): + invoice = self.init_invoice( + "out_invoice", partner=self.partner, amounts=[1000], post=True + ) + wizard = self.create_send_and_print( + invoice, + sending_methods=["email", "manual"], + mail_partner_ids=self.partner, + partner_cc_ids=self.partner_cc, + partner_bcc_ids=self.partner_bcc, + ) + + with self.mock_mail_gateway(): + wizard.action_send_and_print() + self.assertEqual(len(self._mails), 3) + + message = self._get_mail_message(invoice) + self.assertEqual(len(message.mail_ids), 1) + + # Only 3 partners (from default_cc/bcc of company) notified + self.assertEqual(len(message.notified_partner_ids), 3) + self.assertEqual(len(message.notification_ids), 3) diff --git a/mail_composer_cc_bcc_account/wizards/__init__.py b/mail_composer_cc_bcc_account/wizards/__init__.py new file mode 100644 index 000000000..589b902be --- /dev/null +++ b/mail_composer_cc_bcc_account/wizards/__init__.py @@ -0,0 +1 @@ +from . import account_move_send_wizard diff --git a/mail_composer_cc_bcc_account/wizards/account_move_send_wizard.py b/mail_composer_cc_bcc_account/wizards/account_move_send_wizard.py new file mode 100644 index 000000000..d7a77dba3 --- /dev/null +++ b/mail_composer_cc_bcc_account/wizards/account_move_send_wizard.py @@ -0,0 +1,78 @@ +# Copyright 2024 Camptocamp +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +# +from odoo import Command, api, fields, models +from odoo.tools.mail import email_split + + +class AccountMoveSendWizard(models.TransientModel): + _inherit = "account.move.send.wizard" + + partner_cc_ids = fields.Many2many( + "res.partner", + "account_move_send_wizard_res_partner_cc_rel", + "wizard_id", + "partner_id", + string="Cc", + compute="_compute_mail_partner_cc_bcc_ids", + store=True, + readonly=False, + ) + partner_bcc_ids = fields.Many2many( + "res.partner", + "account_move_send_wizard_res_partner_bcc_rel", + "wizard_id", + "partner_id", + string="Bcc", + compute="_compute_mail_partner_cc_bcc_ids", + store=True, + readonly=False, + ) + + # ------------------------------------------------------------------------- + # DEFAULTS + # ------------------------------------------------------------------------- + + @api.model + def default_get(self, fields_list): + # EXTENDS 'base' + results = super().default_get(fields_list) + company = self.env.company + partner_cc = company.default_partner_cc_ids + if partner_cc: + results["partner_cc_ids"] = [Command.set(partner_cc.ids)] + partner_bcc = company.default_partner_bcc_ids + if partner_bcc: + results["partner_bcc_ids"] = [Command.set(partner_bcc.ids)] + return results + + # ------------------------------------------------------------------------- + # COMPUTE METHODS + # ------------------------------------------------------------------------- + def _get_partner_ids_from_mail(self, move, emails): + partners = self.env["res.partner"].with_company(move.company_id) + for mail_data in email_split(emails): + partners |= partners.find_or_create(mail_data) + return partners + + @api.depends("mail_template_id") + def _compute_mail_partner_cc_bcc_ids(self): + for wizard in self: + if wizard.mail_template_id: + wizard.partner_cc_ids = self._get_partner_ids_from_mail( + wizard.move_id, wizard.mail_template_id.email_cc + ) + wizard.partner_bcc_ids = self._get_partner_ids_from_mail( + wizard.move_id, wizard.mail_template_id.email_bcc + ) + else: + wizard.partner_cc_ids = wizard.partner_bcc_ids = None + + @api.model + def _send_mail(self, move, mail_template, **kwargs): + move_with_context = move.with_context( + is_from_composer=True, + partner_cc_ids=self.partner_cc_ids, + partner_bcc_ids=self.partner_bcc_ids, + ) + return super()._send_mail(move_with_context, mail_template, **kwargs) diff --git a/mail_composer_cc_bcc_account/wizards/account_move_send_wizard.xml b/mail_composer_cc_bcc_account/wizards/account_move_send_wizard.xml new file mode 100644 index 000000000..31db713f5 --- /dev/null +++ b/mail_composer_cc_bcc_account/wizards/account_move_send_wizard.xml @@ -0,0 +1,25 @@ + + + + account.move.send.wizard.form.inherit + account.move.send.wizard + + + + + + + + + +