[MIG] mail_composer_cc_bcc_account: Migration to 17.0

pull/1312/head
trisdoan 2024-02-19 15:18:08 +07:00
parent 2f8bea8d5d
commit 217a993878
23 changed files with 277 additions and 114 deletions

View File

@ -61,14 +61,14 @@ Configuration
In company form there are two fields to set default cc and bcc partners. In company form there are two fields to set default cc and bcc partners.
|image| |res_company_form_default_cc_bcc|
In template form there are two fields to set cc and bcc emails. In template form there are two fields to set cc and bcc emails.
|image1| |email_template_form_cc_bcc|
.. |image| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_composer_cc_bcc/static/img/res_company_form_default_cc_bcc.png .. |res_company_form_default_cc_bcc| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_composer_cc_bcc/static/img/res_company_form_default_cc_bcc.png
.. |image1| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_composer_cc_bcc/static/img/email_template_form_cc_bcc.png .. |email_template_form_cc_bcc| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_composer_cc_bcc/static/img/email_template_form_cc_bcc.png
Usage Usage
===== =====

View File

@ -15,7 +15,6 @@
"preloadable": True, "preloadable": True,
"depends": [ "depends": [
"mail", "mail",
"account",
], ],
"data": [ "data": [
"views/res_company_views.xml", "views/res_company_views.xml",

View File

@ -1,7 +1,7 @@
In company form there are two fields to set default cc and bcc partners. In company form there are two fields to set default cc and bcc partners.
> ![image](../static/img/res_company_form_default_cc_bcc.png) > ![res_company_form_default_cc_bcc](../static/img/res_company_form_default_cc_bcc.png)
In template form there are two fields to set cc and bcc emails. In template form there are two fields to set cc and bcc emails.
> ![image](../static/img/email_template_form_cc_bcc.png) > ![email_template_form_cc_bcc](../static/img/email_template_form_cc_bcc.png)

View File

@ -8,10 +8,11 @@
/* /*
:Author: David Goodger (goodger@python.org) :Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ :Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain. :Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils. Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet. customize this style sheet.
@ -274,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ; margin-left: 2em ;
margin-right: 2em } margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */ pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee } pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 } pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@ -300,7 +301,7 @@ span.option {
span.pre { span.pre {
white-space: pre } white-space: pre }
span.problematic { span.problematic, pre.problematic {
color: red } color: red }
span.section-subtitle { span.section-subtitle {
@ -366,23 +367,24 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5e1148fbb1ae19217b0286fcf623c67d487dbee6edd8b1fc072ce53c825f9a0b !! source digest: sha256:254245c99d868f3a2c4cfdfec26f8d1be09fdc4b8bd2ec691e7f1db4cda9902b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.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_composer_cc_bcc"><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_composer_cc_bcc"><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><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.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_composer_cc_bcc"><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_composer_cc_bcc"><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>Odoo native does not support defining a Cc field in the Mail Composer <p>Odoo native does not support defining a Cc field in the Mail Composer by
by default; instead, it only has a unique Recipients fields, which is default; instead, it only has a unique Recipients fields, which is
confusing for a lot of end users.</p> confusing for a lot of end users.</p>
<p>This module allows to properly separate To:, Cc:, and Bcc: fields <p>This module allows to properly separate To:, Cc:, and Bcc: fields in the
in the Mail Composer.</p> Mail Composer.</p>
<div class="section" id="features"> <div class="section" id="features">
<h1>Features</h1> <h1>Features</h1>
<ul class="simple"> <ul class="simple">
<li>Add Cc and Bcc fields to mail composer form. Send only once to multiple email <li>Add Cc and Bcc fields to mail composer form. Send only once to
addresses.</li> multiple email addresses.</li>
<li>Add Cc and Bcc fields to company form to use them as default in mail composer <li>Add Cc and Bcc fields to company form to use them as default in mail
form.</li> composer form.</li>
<li>Add Bcc field to mail template form. Use Cc and Bcc fields to lookup partners <li>Add Bcc field to mail template form. Use Cc and Bcc fields to lookup
by email then add them to corresponding fields in mail composer form.</li> partners by email then add them to corresponding fields in mail
composer form.</li>
</ul> </ul>
<div class="admonition important"> <div class="admonition important">
<p class="first admonition-title">Important</p> <p class="first admonition-title">Important</p>
@ -402,34 +404,30 @@ Only for development or testing purpose, do not use in production.
</div> </div>
<div class="section" id="configuration"> <div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2> <h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<p>In company form there are two fields to set default cc and bcc <p>In company form there are two fields to set default cc and bcc partners.</p>
partners.</p>
<blockquote> <blockquote>
<img alt="https://raw.githubusercontent.com/OCA/social/16.0/mail_composer_cc_bcc/static/img/res_company_form_default_cc_bcc.png" src="https://raw.githubusercontent.com/OCA/social/16.0/mail_composer_cc_bcc/static/img/res_company_form_default_cc_bcc.png" /> <img alt="res_company_form_default_cc_bcc" src="https://raw.githubusercontent.com/OCA/social/17.0/mail_composer_cc_bcc/static/img/res_company_form_default_cc_bcc.png" /></blockquote>
</blockquote>
<p>In template form there are two fields to set cc and bcc emails.</p> <p>In template form there are two fields to set cc and bcc emails.</p>
<blockquote> <blockquote>
<img alt="https://raw.githubusercontent.com/OCA/social/16.0/mail_composer_cc_bcc/static/img/email_template_form_cc_bcc.png" src="https://raw.githubusercontent.com/OCA/social/16.0/mail_composer_cc_bcc/static/img/email_template_form_cc_bcc.png" /> <img alt="email_template_form_cc_bcc" src="https://raw.githubusercontent.com/OCA/social/17.0/mail_composer_cc_bcc/static/img/email_template_form_cc_bcc.png" /></blockquote>
</blockquote>
</div> </div>
<div class="section" id="usage"> <div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2> <h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
<p>The partners cc and bcc from company form will be used to fill in mail composer <p>The partners cc and bcc from company form will be used to fill in mail
form.</p> composer form.</p>
<blockquote> <blockquote>
<img alt="https://raw.githubusercontent.com/OCA/social/16.0/mail_composer_cc_bcc/static/img/mail_compose_message_default_cc_bcc.png" src="https://raw.githubusercontent.com/OCA/social/16.0/mail_composer_cc_bcc/static/img/mail_compose_message_default_cc_bcc.png" /> <img alt="image" src="https://raw.githubusercontent.com/OCA/social/17.0/mail_composer_cc_bcc/static/img/mail_compose_message_default_cc_bcc.png" /></blockquote>
</blockquote> <p>When select a template that has cc and/or bcc emails, the emails will be
<p>When select a template that has cc and/or bcc emails, the emails will be used used to lookup partners then found partners will be added to
to lookup partners then found partners will be added to corresponding mail corresponding mail composers fields.</p>
composers fields.</p>
<blockquote> <blockquote>
<img alt="https://raw.githubusercontent.com/OCA/social/16.0/mail_composer_cc_bcc/static/img/mail_compose_message_template_cc_bcc.png" src="https://raw.githubusercontent.com/OCA/social/16.0/mail_composer_cc_bcc/static/img/mail_compose_message_template_cc_bcc.png" /> <img alt="image1" src="https://raw.githubusercontent.com/OCA/social/17.0/mail_composer_cc_bcc/static/img/mail_compose_message_template_cc_bcc.png" /></blockquote>
</blockquote>
</div> </div>
<div class="section" id="known-issues-roadmap"> <div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h2> <h2><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h2>
<ul class="simple"> <ul class="simple">
<li>Extract <cite>account</cite> customization (<cite>account.invoice.send</cite> wizard) to a specific module <cite>mail_composer_cc_bcc_account</cite></li> <li>Extract account customization (account.invoice.send wizard) to a
specific module mail_composer_cc_bcc_account</li>
</ul> </ul>
</div> </div>
<div class="section" id="bug-tracker"> <div class="section" id="bug-tracker">
@ -437,7 +435,7 @@ composers fields.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>. <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. 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 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_composer_cc_bcc%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_composer_cc_bcc%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> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -447,7 +445,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<div class="section" id="authors"> <div class="section" id="authors">
<h1>Authors</h1> <h1>Authors</h1>
<ul class="simple"> <ul class="simple">
<li>Camptocamp SA</li> <li>Camptocamp</li>
</ul> </ul>
</div> </div>
<div class="section" id="contributors"> <div class="section" id="contributors">
@ -458,6 +456,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<ul class="simple"> <ul class="simple">
<li>Hai N. Le &lt;<a class="reference external" href="mailto:hailn&#64;trobz.com">hailn&#64;trobz.com</a>&gt;</li> <li>Hai N. Le &lt;<a class="reference external" href="mailto:hailn&#64;trobz.com">hailn&#64;trobz.com</a>&gt;</li>
<li>Son Ho &lt;<a class="reference external" href="mailto:sonhd&#64;trobz.com">sonhd&#64;trobz.com</a>&gt;</li> <li>Son Ho &lt;<a class="reference external" href="mailto:sonhd&#64;trobz.com">sonhd&#64;trobz.com</a>&gt;</li>
<li>Tri Doan &lt;<a class="reference external" href="mailto:tridm&#64;trobz.com">tridm&#64;trobz.com</a>&gt;</li>
</ul> </ul>
</blockquote> </blockquote>
</li> </li>
@ -465,18 +464,21 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
</div> </div>
<div class="section" id="other-credits"> <div class="section" id="other-credits">
<h1>Other credits</h1> <h1>Other credits</h1>
<p>The creation and migration from 15.0 to 16.0 of this module were financially supported by Camptocamp.</p> <p>The creation and migration from 16.0 to 17.0 of this module were
financially supported by Camptocamp.</p>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h1>Maintainers</h1> <h1>Maintainers</h1>
<p>This module is maintained by the OCA.</p> <p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p> <p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/hailangvn2023"><img alt="hailangvn2023" src="https://github.com/hailangvn2023.png?size=40px" /></a></p> <p><a class="reference external image-reference" href="https://github.com/trisdoan"><img alt="trisdoan" src="https://github.com/trisdoan.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/16.0/mail_composer_cc_bcc">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_composer_cc_bcc">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> <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>
</div> </div>

View File

@ -103,8 +103,8 @@ class TestMailCcBcc(TestMailComposerForm):
# Company default values # Company default values
env.company.default_partner_cc_ids = self.partner_cc3 env.company.default_partner_cc_ids = self.partner_cc3
env.company.default_partner_bcc_ids = self.partner_cc2 env.company.default_partner_bcc_ids = self.partner_cc2
# Product template values # Partner template values
tmpl_model = env["ir.model"].search([("model", "=", "product.template")]) tmpl_model = env["ir.model"].search([("model", "=", "res.partner")])
partner_cc = self.partner_cc partner_cc = self.partner_cc
partner_bcc = self.partner_bcc partner_bcc = self.partner_bcc
vals = { vals = {
@ -120,7 +120,7 @@ Test Template<br></p>""",
(partner_bcc.name or "False", partner_bcc.email or "False") (partner_bcc.name or "False", partner_bcc.email or "False")
), ),
} }
prod_tmpl = env["mail.template"].create(vals) partner_tmpl = env["mail.template"].create(vals)
# Open mail composer form and check for default values from company # Open mail composer form and check for default values from company
form = self.open_mail_composer_form() form = self.open_mail_composer_form()
@ -130,12 +130,12 @@ Test Template<br></p>""",
self.assertEqual(composer.partner_bcc_ids, self.partner_cc2) self.assertEqual(composer.partner_bcc_ids, self.partner_cc2)
# Change email template and check for values from it # Change email template and check for values from it
form.template_id = prod_tmpl form.template_id = partner_tmpl
composer = form.save() composer = form.save()
# Beside existing Cc and Bcc, add template's ones # Beside existing Cc and Bcc, add template's ones
form = Form(composer) form = Form(composer)
form.template_id = prod_tmpl form.template_id = partner_tmpl
composer = form.save() composer = form.save()
expecting = self.partner_cc3 + self.partner_cc expecting = self.partner_cc3 + self.partner_cc
@ -153,7 +153,7 @@ Test Template<br></p>""",
form.save() form.save()
self.assertFalse(form.template_id) # no template self.assertFalse(form.template_id) # no template
form.template_id = prod_tmpl form.template_id = partner_tmpl
composer = form.save() composer = form.save()
expecting = self.partner_cc3 + self.partner_cc expecting = self.partner_cc3 + self.partner_cc

View File

@ -17,19 +17,19 @@ Email CC and BCC when sending invoice
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
:target: https://github.com/OCA/social/tree/16.0/mail_composer_cc_bcc_account :target: https://github.com/OCA/social/tree/17.0/mail_composer_cc_bcc_account
:alt: OCA/social :alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |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_composer_cc_bcc_account :target: https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_composer_cc_bcc_account
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png .. |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 :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
This module allows to properly separate To:, Cc:, and Bcc: fields This module allows to properly separate To:, Cc:, and Bcc: fields in
in when sending invoices. when sending invoices.
.. IMPORTANT:: .. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning. This is an alpha version, the data model and design can change at any time without warning.
@ -50,8 +50,8 @@ mail_compose_cc_bcc are installed.
Usage Usage
===== =====
Use the cc and bcc fields when sending invoices, to notify other partners then Use the cc and bcc fields when sending invoices, to notify other
the invoice contact of the customer. partners then the invoice contact of the customer.
Bug Tracker Bug Tracker
=========== ===========
@ -59,7 +59,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_. 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. 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 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_composer_cc_bcc_account%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_composer_cc_bcc_account%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. Do not contact contributors directly about support or help with technical issues.
@ -67,29 +67,31 @@ Credits
======= =======
Authors Authors
~~~~~~~ -------
* Camptocamp SA * Camptocamp SA
Contributors Contributors
~~~~~~~~~~~~ ------------
* `Trobz <https://www.trobz.com>`_: - `Trobz <https://www.trobz.com>`__:
* Hai N. Le <hailn@trobz.com> - Hai N. Le <hailn@trobz.com>
* Son Ho <sonhd@trobz.com> - Son Ho <sonhd@trobz.com>
- Tris Doan <tridm@trobz.com>
* `Therp BV <https://therp.nl>`_: - `Therp BV <https://therp.nl>`__:
* Ronald Portier <ronald@therp.nl> - Ronald Portier <ronald@therp.nl>
Other credits Other credits
~~~~~~~~~~~~~ -------------
The creation and migration from 15.0 to 16.0 of this module were financially supported by Camptocamp. The creation and migration from 16.0 to 17.0 of this module were
financially supported by Camptocamp.
Maintainers Maintainers
~~~~~~~~~~~ -----------
This module is maintained by the OCA. This module is maintained by the OCA.
@ -109,6 +111,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-hailangvn2023| |maintainer-hailangvn2023|
This module is part of the `OCA/social <https://github.com/OCA/social/tree/16.0/mail_composer_cc_bcc_account>`_ project on GitHub. This module is part of the `OCA/social <https://github.com/OCA/social/tree/17.0/mail_composer_cc_bcc_account>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -1 +1,5 @@
# Copyright 2024 Camptocamp
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models
from . import wizards

View File

@ -3,7 +3,7 @@
{ {
"name": "Email CC and BCC when sending invoice", "name": "Email CC and BCC when sending invoice",
"summary": "This module enables sending mail to CC and BCC partners for invoices.", "summary": "This module enables sending mail to CC and BCC partners for invoices.",
"version": "16.0.2.0.0", "version": "17.0.1.0.0",
"development_status": "Alpha", "development_status": "Alpha",
"category": "Social", "category": "Social",
"website": "https://github.com/OCA/social", "website": "https://github.com/OCA/social",
@ -15,10 +15,10 @@
"auto_install": True, "auto_install": True,
"preloadable": True, "preloadable": True,
"depends": [ "depends": [
"mail_composer_cc_bcc",
"account", "account",
"mail_composer_cc_bcc",
], ],
"data": [ "data": [
"wizards/account_invoice_send_views.xml", "wizards/account_move_send.xml",
], ],
} }

View File

@ -0,0 +1 @@
from . import mail_thread

View File

@ -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

View File

@ -1,2 +1 @@
This module will be automatically installed if both account and This module will be automatically installed if both account and mail_compose_cc_bcc are installed.
mail_compose_cc_bcc are installed.

View File

@ -1,2 +0,0 @@
This module will be automatically installed if both account and
mail_compose_cc_bcc are installed.

View File

@ -1,8 +0,0 @@
* `Trobz <https://www.trobz.com>`_:
* Hai N. Le <hailn@trobz.com>
* Son Ho <sonhd@trobz.com>
* `Therp BV <https://therp.nl>`_:
* Ronald Portier <ronald@therp.nl>

View File

@ -1,2 +1,2 @@
The creation and migration from 15.0 to 16.0 of this module were The creation and migration from 16.0 to 17.0 of this module were
financially supported by Camptocamp. financially supported by Camptocamp.

View File

@ -1 +0,0 @@
The creation and migration from 15.0 to 16.0 of this module were financially supported by Camptocamp.

View File

@ -1,2 +0,0 @@
This module allows to properly separate To:, Cc:, and Bcc: fields
in when sending invoices.

View File

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

View File

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

View File

@ -8,10 +8,11 @@
/* /*
:Author: David Goodger (goodger@python.org) :Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ :Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain. :Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils. Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet. customize this style sheet.
@ -274,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ; margin-left: 2em ;
margin-right: 2em } margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */ pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee } pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 } pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@ -300,7 +301,7 @@ span.option {
span.pre { span.pre {
white-space: pre } white-space: pre }
span.problematic { span.problematic, pre.problematic {
color: red } color: red }
span.section-subtitle { span.section-subtitle {
@ -441,13 +442,15 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
</div> </div>
<div class="section" id="other-credits"> <div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-7">Other credits</a></h2> <h2><a class="toc-backref" href="#toc-entry-7">Other credits</a></h2>
<p>The creation and migration from 15.0 to 16.0 of this module were <p>The creation and migration from 16.0 to 17.0 of this module were
financially supported by Camptocamp.</p> financially supported by Camptocamp.</p>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2> <h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p> <p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>

View File

@ -1,5 +1,6 @@
# Copyright 2023 Camptocamp # Copyright 2023 Camptocamp
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from datetime import date
from odoo.tests import Form from odoo.tests import Form
@ -9,31 +10,49 @@ from odoo.addons.mail_composer_cc_bcc.tests.test_mail_cc_bcc import TestMailCcBc
class TestMailCcBccInvoice(TestMailCcBcc): class TestMailCcBccInvoice(TestMailCcBcc):
def open_invoice_mail_composer_form(self): def open_invoice_mail_composer_form(self):
# Use form to populate data # Use form to populate data
for_name = [("name", "like", "%INV/20__/00003")] # init invoice data
self.test_invoice = test_record = self.env["account.move"].search(for_name) self.test_invoice = test_record = self.test_account_move = self.env[
"account.move"
].create(
{
"invoice_date": date(2024, 3, 2),
"invoice_date_due": date(2024, 3, 10),
"invoice_line_ids": [
(0, 0, {"name": "Line1", "price_unit": 100.0}),
(0, 0, {"name": "Line2", "price_unit": 200.0}),
],
"move_type": "out_invoice",
"name": "invoice test",
"partner_id": self.env.ref("base.res_partner_2").id,
}
)
self.assertTrue( self.assertTrue(
self.test_invoice, self.test_invoice,
"Test setup did not succeeed. Invoice not found.", "Test setup did not succeed. Invoice not found.",
) )
self.test_invoice.write({"state": "posted"})
ctx = { ctx = {
"active_ids": test_record.ids, "active_ids": test_record.ids,
"default_model": "account.move", "default_model": "account.move",
"default_res_id": test_record.id, "default_res_id": test_record.id,
"mail_notify_force_send": True, "mail_notify_force_send": True,
} }
form = Form(self.env["account.invoice.send"].with_context(**ctx)) form = Form(self.env["account.move.send"].with_context(**ctx))
form.body = "<p>Hello</p>" form.mail_body = "<p>Hello</p>"
return form return form
def test_invoice_mail_cc_bcc(self): def test_invoice_mail_cc_bcc(self):
self.set_company() self.set_company()
form = self.open_invoice_mail_composer_form() form = self.open_invoice_mail_composer_form()
form.subject = "Hello" form.mail_subject = "Hello"
composer = form.save() composer = form.save()
with self.mock_mail_gateway(): with self.mock_mail_gateway():
composer._send_email() composer.action_send_and_print()
message = self.test_invoice.message_ids[0] message = self.test_invoice.message_ids[0]
self.assertEqual(len(message.mail_ids), 1) self.assertEqual(len(message.mail_ids), 1)
# Only 4 partners notified
self.assertEqual(len(message.notified_partner_ids), 4) # Only 2 partners (from default_cc/bcc of company) notified
self.assertEqual(len(message.notification_ids), 4) self.assertEqual(len(message.notified_partner_ids), 2)
self.assertEqual(len(message.notification_ids), 2)

View File

@ -0,0 +1 @@
from . import account_move_send

View File

@ -0,0 +1,129 @@
# Copyright 2024 Camptocamp
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import Command, api, fields, models, tools
class AccountMoveSend(models.TransientModel):
_inherit = "account.move.send"
partner_cc_ids = fields.Many2many(
"res.partner",
"account_move_send_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_res_partner_bcc_rel",
"wizard_id",
"partner_id",
string="Bcc",
compute="_compute_mail_partner_cc_bcc_ids",
store=True,
readonly=False,
)
def _get_partner_ids_from_mail(self, move, emails):
partners = self.env["res.partner"].with_company(move.company_id)
for mail_data in tools.email_split(emails):
partners |= partners.find_or_create(mail_data)
return partners
@api.model
def default_get(self, fields_list):
company = self.env.company
res = super().default_get(fields_list)
partner_cc = company.default_partner_cc_ids
if partner_cc:
res["partner_cc_ids"] = [Command.set(partner_cc.ids)]
partner_bcc = company.default_partner_bcc_ids
if partner_bcc:
res["partner_bcc_ids"] = [Command.set(partner_bcc.ids)]
return res
@api.depends("mail_template_id")
def _compute_mail_partner_cc_bcc_ids(self):
for wizard in self:
if wizard.mode == "invoice_single" and wizard.mail_template_id:
wizard.partner_cc_ids = self._get_partner_ids_from_mail(
wizard.move_ids, wizard.mail_template_id.email_cc
)
wizard.partner_bcc_ids = self._get_partner_ids_from_mail(
wizard.move_ids, wizard.mail_template_id.email_bcc
)
else:
wizard.partner_cc_ids = None
wizard.partner_bcc_ids = None
def _get_mail_move_values(self, move, wizard=None):
mail_template_id = (
move.send_and_print_values
and move.send_and_print_values.get("mail_template_id")
)
mail_template = (
wizard
and wizard.mail_template_id
or self.env["mail.template"].browse(mail_template_id)
)
mail_lang = self._get_default_mail_lang(move, mail_template)
return {
"mail_template_id": mail_template,
"mail_lang": mail_lang,
"mail_body": wizard
and wizard.mail_body
or self._get_default_mail_body(move, mail_template, mail_lang),
"mail_subject": wizard
and wizard.mail_subject
or self._get_default_mail_subject(move, mail_template, mail_lang),
"mail_partner_ids": wizard
and wizard.mail_partner_ids
or self._get_default_mail_partner_ids(move, mail_template, mail_lang),
"mail_attachments_widget": wizard
and wizard.mail_attachments_widget
or self._get_default_mail_attachments_widget(move, mail_template),
"partner_cc_ids": wizard
and wizard.partner_cc_ids
or self._get_default_mail_partner_cc_ids(move, mail_template),
"partner_bcc_ids": wizard
and wizard.partner_bcc_ids
or self._get_default_mail_partner_bcc_ids(move, mail_template),
}
# -------------------------------------------------------------------------
# BUSINESS ACTIONS
# -------------------------------------------------------------------------
@api.model
def _send_mail(self, move, mail_template, **kwargs):
"""Send the journal entry passed as parameter by mail."""
partner_ids = kwargs.get("partner_ids", [])
move_with_context = move.with_context(
no_new_invoice=True,
mail_notify_author=self.env.user.partner_id.id in partner_ids,
is_from_composer=True,
partner_cc_ids=self.partner_cc_ids,
partner_bcc_ids=self.partner_bcc_ids,
)
extra_args = {
"email_layout_xmlid": "mail.mail_notification_layout_with_responsible_signature", # noqa: E501
"email_add_signature": not mail_template,
"mail_auto_delete": mail_template.auto_delete,
"mail_server_id": mail_template.mail_server_id.id,
"reply_to_force_new": False,
"message_type": "comment",
}
kwargs.update(extra_args)
new_message = move_with_context.message_post(**kwargs)
# Prevent duplicated attachments linked to the invoice.
new_message.attachment_ids.write(
{
"res_model": new_message._name,
"res_id": new_message.id,
}
)

View File

@ -1,23 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<odoo> <odoo>
<record id="account_invoice_send_wizard_form_inherit" model="ir.ui.view"> <record id="account_move_send_form_inherit" model="ir.ui.view">
<field name="name">account.invoice.send.form.inherit</field> <field name="name">account.move.send.form.inherit</field>
<field name="model">account.invoice.send</field> <field name="model">account.move.send</field>
<field name="inherit_id" ref="account.account_invoice_send_wizard_form" /> <field name="inherit_id" ref="account.account_move_send_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='partner_ids']/.." position="after"> <xpath expr="//field[@name='mail_partner_ids']/.." position="after">
<field name='mode' invisible="1" />
<field <field
name="partner_cc_ids" name="partner_cc_ids"
widget="many2many_tags_email" widget="many2many_tags_email"
context="{'force_email':True, 'show_email':True}" context="{'force_email':True, 'show_email':True}"
attrs="{'invisible': [('composition_mode', '!=', 'comment')]}" invisible="mode == 'invoice_multi'"
/> />
<field <field
name="partner_bcc_ids" name="partner_bcc_ids"
widget="many2many_tags_email" widget="many2many_tags_email"
context="{'force_email':True, 'show_email':True}" context="{'force_email':True, 'show_email':True}"
attrs="{'invisible': [('composition_mode', '!=', 'comment')]}" invisible="mode == 'invoice_multi'"
/> />
</xpath> </xpath>
</field> </field>