Skip to content

Commit

Permalink
[FIX] mail_composer_cc_bcc: send RFQ by email
Browse files Browse the repository at this point in the history
  • Loading branch information
trisdoan committed Dec 10, 2024
1 parent 0b4ad2c commit a6eec5b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
3 changes: 2 additions & 1 deletion mail_composer_cc_bcc/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Email CC and BCC
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:8cd84f469349cde2e0c377b6cb5fdb8a21ad9e4f6e76a1a97cb5dc930ec14624
!! source digest: sha256:6ce93368b685f5752b0d7cdce64fb308a3aa3d112094a630b2df8cedda9ae812
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
Expand Down Expand Up @@ -105,6 +105,7 @@ Contributors
* `Trobz <https://www.trobz.com>`_:

* Hai N. Le <hailn@trobz.com>
* Tri Doan <tridm@trobz.com>

Other credits
~~~~~~~~~~~~~
Expand Down
29 changes: 21 additions & 8 deletions mail_composer_cc_bcc/models/mail_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ class MailThread(models.AbstractModel):
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
for message in res:
if message.message_type == "notification":
continue
partners_cc = context.get("partner_cc_ids", None)
if partners_cc:
message.recipient_cc_ids = partners_cc
partners_bcc = context.get("partner_bcc_ids", None)
if partners_bcc:
message.recipient_bcc_ids = partners_bcc
return res

def _notify_by_email_add_values(self, base_mail_values):
Expand Down Expand Up @@ -46,7 +49,8 @@ def _notify_compute_recipients(self, message, msg_vals):
rdata = super()._notify_compute_recipients(message, msg_vals)
context = self.env.context
is_from_composer = context.get("is_from_composer", False)
if not is_from_composer:
skip_adding_cc_bcc = context.get("skip_adding_cc_bcc", False)
if not is_from_composer or skip_adding_cc_bcc:
return rdata
for pdata in rdata:
pdata["type"] = "customer"
Expand Down Expand Up @@ -83,6 +87,9 @@ def _notify_email_recipient_values(self, recipient_ids):
"""
res = super()._notify_email_recipient_values(recipient_ids)
context = self.env.context
skip_adding_cc_bcc = context.get("skip_adding_cc_bcc", False)
if skip_adding_cc_bcc:
return res

Check warning on line 92 in mail_composer_cc_bcc/models/mail_thread.py

View check run for this annotation

Codecov / codecov/patch

mail_composer_cc_bcc/models/mail_thread.py#L92

Added line #L92 was not covered by tests
r_ids = list(recipient_ids)
partners_cc = context.get("partner_cc_ids", None)
if partners_cc:
Expand All @@ -99,7 +106,8 @@ def _notify_classify_recipients(self, recipient_data, model_name, msg_vals=None)
recipient_data, model_name, msg_vals=msg_vals
)
is_from_composer = self.env.context.get("is_from_composer", False)
if not is_from_composer:
skip_adding_cc_bcc = self.env.context.get("skip_adding_cc_bcc", False)
if not is_from_composer or skip_adding_cc_bcc:
return res
ids = []
customer_data = None
Expand All @@ -115,3 +123,8 @@ def _notify_classify_recipients(self, recipient_data, model_name, msg_vals=None)
else:
customer_data["recipients"] += ids
return [customer_data]

def _notify_thread(self, message, msg_vals=False, **kwargs):
if message.message_type == "notification":
self = self.with_context(skip_adding_cc_bcc=True)
return super(MailThread, self)._notify_thread(message, msg_vals, **kwargs)
1 change: 1 addition & 0 deletions mail_composer_cc_bcc/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* `Trobz <https://www.trobz.com>`_:

* Hai N. Le <hailn@trobz.com>
* Tri Doan <tridm@trobz.com>
4 changes: 3 additions & 1 deletion mail_composer_cc_bcc/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 @@ -367,7 +368,7 @@ <h1 class="title">Email CC and BCC</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:8cd84f469349cde2e0c377b6cb5fdb8a21ad9e4f6e76a1a97cb5dc930ec14624
!! source digest: sha256:6ce93368b685f5752b0d7cdce64fb308a3aa3d112094a630b2df8cedda9ae812
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/15.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-15-0/social-15-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=15.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
Expand Down Expand Up @@ -451,6 +452,7 @@ <h1>Contributors</h1>
<blockquote>
<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>Tri Doan &lt;<a class="reference external" href="mailto:tridm&#64;trobz.com">tridm&#64;trobz.com</a>&gt;</li>
</ul>
</blockquote>
</li>
Expand Down

0 comments on commit a6eec5b

Please sign in to comment.