Skip to content

Commit

Permalink
[MIG] mail_composer_cc_bcc_account: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
trisdoan committed Apr 21, 2024
1 parent 1f0d246 commit dcbc48f
Show file tree
Hide file tree
Showing 20 changed files with 236 additions and 67 deletions.
1 change: 0 additions & 1 deletion mail_composer_cc_bcc/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"preloadable": True,
"depends": [
"mail",
"account",
],
"data": [
"views/res_company_views.xml",
Expand Down
12 changes: 6 additions & 6 deletions mail_composer_cc_bcc/tests/test_mail_cc_bcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def test_template_cc_bcc(self):
# Company default values
env.company.default_partner_cc_ids = self.partner_cc3
env.company.default_partner_bcc_ids = self.partner_cc2
# Product template values
tmpl_model = env["ir.model"].search([("model", "=", "product.template")])
# Partner template values
tmpl_model = env["ir.model"].search([("model", "=", "res.partner")])
partner_cc = self.partner_cc
partner_bcc = self.partner_bcc
vals = {
Expand All @@ -120,7 +120,7 @@ def test_template_cc_bcc(self):
(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
form = self.open_mail_composer_form()
Expand All @@ -130,12 +130,12 @@ def test_template_cc_bcc(self):
self.assertEqual(composer.partner_bcc_ids, self.partner_cc2)

# Change email template and check for values from it
form.template_id = prod_tmpl
form.template_id = partner_tmpl
composer = form.save()

# Beside existing Cc and Bcc, add template's ones
form = Form(composer)
form.template_id = prod_tmpl
form.template_id = partner_tmpl
composer = form.save()
expecting = self.partner_cc3 + self.partner_cc

Expand All @@ -153,7 +153,7 @@ def test_template_cc_bcc(self):
form.save()
self.assertFalse(form.template_id) # no template

form.template_id = prod_tmpl
form.template_id = partner_tmpl
composer = form.save()

expecting = self.partner_cc3 + self.partner_cc
Expand Down
40 changes: 21 additions & 19 deletions mail_composer_cc_bcc_account/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ Email CC and BCC when sending invoice
: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_composer_cc_bcc_account
:target: https://github.com/OCA/social/tree/17.0/mail_composer_cc_bcc_account
: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_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
.. |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 allows to properly separate To:, Cc:, and Bcc: fields
in when sending invoices.
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.
Expand All @@ -50,46 +50,48 @@ 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.
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 <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_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.

Credits
=======

Authors
~~~~~~~
-------

* Camptocamp SA

Contributors
~~~~~~~~~~~~
------------

* `Trobz <https://www.trobz.com>`_:
- `Trobz <https://www.trobz.com>`__:

* Hai N. Le <hailn@trobz.com>
* Son Ho <sonhd@trobz.com>
- Hai N. Le <hailn@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
~~~~~~~~~~~~~
-------------

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

This module is maintained by the OCA.

Expand All @@ -109,6 +111,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|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.
4 changes: 4 additions & 0 deletions mail_composer_cc_bcc_account/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Copyright 2024 Camptocamp
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
from . import wizards
6 changes: 3 additions & 3 deletions mail_composer_cc_bcc_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Email CC and BCC when sending invoice",
"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",
"category": "Social",
"website": "https://github.com/OCA/social",
Expand All @@ -15,10 +15,10 @@
"auto_install": True,
"preloadable": True,
"depends": [
"mail_composer_cc_bcc",
"account",
"mail_composer_cc_bcc",
],
"data": [
"wizards/account_invoice_send_views.xml",
"wizards/account_move_send.xml",
],
}
1 change: 1 addition & 0 deletions mail_composer_cc_bcc_account/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import mail_thread
19 changes: 19 additions & 0 deletions mail_composer_cc_bcc_account/models/mail_thread.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions mail_composer_cc_bcc_account/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
This module will be automatically installed if both account and
mail_compose_cc_bcc are installed.
This module will be automatically installed if both account and mail_compose_cc_bcc are installed.
2 changes: 0 additions & 2 deletions mail_composer_cc_bcc_account/readme/CONFIGURE.rst

This file was deleted.

8 changes: 0 additions & 8 deletions mail_composer_cc_bcc_account/readme/CONTRIBUTORS.rst

This file was deleted.

2 changes: 1 addition & 1 deletion mail_composer_cc_bcc_account/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 0 additions & 1 deletion mail_composer_cc_bcc_account/readme/CREDITS.rst

This file was deleted.

2 changes: 0 additions & 2 deletions mail_composer_cc_bcc_account/readme/DESCRIPTION.rst

This file was deleted.

3 changes: 1 addition & 2 deletions mail_composer_cc_bcc_account/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Use the cc and bcc fields when sending invoices, to notify other
partners then the invoice contact of the customer.
Use the cc and bcc fields when sending invoices, to notify other partners then the invoice contact of the customer.
2 changes: 0 additions & 2 deletions mail_composer_cc_bcc_account/readme/USAGE.rst

This file was deleted.

3 changes: 2 additions & 1 deletion mail_composer_cc_bcc_account/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -441,7 +442,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
</div>
<div class="section" id="other-credits">
<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>
</div>
<div class="section" id="maintainers">
Expand Down
39 changes: 29 additions & 10 deletions mail_composer_cc_bcc_account/tests/test_mail_cc_bcc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2023 Camptocamp
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from datetime import date

from odoo.tests import Form

Expand All @@ -9,31 +10,49 @@
class TestMailCcBccInvoice(TestMailCcBcc):
def open_invoice_mail_composer_form(self):
# Use form to populate data
for_name = [("name", "like", "%INV/20__/00003")]
self.test_invoice = test_record = self.env["account.move"].search(for_name)
# init invoice data
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.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 = {
"active_ids": test_record.ids,
"default_model": "account.move",
"default_res_id": test_record.id,
"mail_notify_force_send": True,
}
form = Form(self.env["account.invoice.send"].with_context(**ctx))
form.body = "<p>Hello</p>"
form = Form(self.env["account.move.send"].with_context(**ctx))
form.mail_body = "<p>Hello</p>"
return form

def test_invoice_mail_cc_bcc(self):
self.set_company()
form = self.open_invoice_mail_composer_form()
form.subject = "Hello"
form.mail_subject = "Hello"
composer = form.save()
with self.mock_mail_gateway():
composer._send_email()
composer.action_send_and_print()
message = self.test_invoice.message_ids[0]
self.assertEqual(len(message.mail_ids), 1)
# Only 4 partners notified
self.assertEqual(len(message.notified_partner_ids), 4)
self.assertEqual(len(message.notification_ids), 4)

# Only 2 partners (from default_cc/bcc of company) notified
self.assertEqual(len(message.notified_partner_ids), 2)
self.assertEqual(len(message.notification_ids), 2)
1 change: 1 addition & 0 deletions mail_composer_cc_bcc_account/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_move_send
Loading

0 comments on commit dcbc48f

Please sign in to comment.