Skip to content

Commit e653654

Browse files
committed
[IMP] Update code to match with v19
1 parent af5d8f3 commit e653654

6 files changed

Lines changed: 39 additions & 35 deletions

File tree

mail_composer_cc_bcc/README.rst

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ all headers (To, Cc, Bcc) in all emails
4545
Features
4646
--------
4747

48-
- Add Cc and Bcc fields to company form to use them as default in mail
49-
composer form.
50-
- Add Bcc field to mail template form. Use Cc and Bcc fields to lookup
51-
partners by email then add them to corresponding fields in mail
52-
composer form.
48+
- Add Cc and Bcc fields to company form to use them as default in mail
49+
composer form.
50+
- Add Bcc field to mail template form. Use Cc and Bcc fields to lookup
51+
partners by email then add them to corresponding fields in mail
52+
composer form.
5353

5454
.. IMPORTANT::
5555
This is an alpha version, the data model and design can change at any time without warning.
@@ -113,13 +113,18 @@ Authors
113113
Contributors
114114
------------
115115

116-
- `Trobz <https://www.trobz.com>`__:
116+
- `Trobz <https://www.trobz.com>`__:
117117

118-
- Hai N. Le <hailn@trobz.com>
119-
- Son Ho <sonhd@trobz.com>
120-
- Tri Doan <tridm@trobz.com>
118+
- Hai N. Le <hailn@trobz.com>
119+
- Son Ho <sonhd@trobz.com>
120+
- Tri Doan <tridm@trobz.com>
121121

122-
- Alberto Nieto alberto.nieto@braintec.com (https://braintec.com)
122+
- Alberto Nieto alberto.nieto@braintec.com (https://braintec.com)
123+
124+
- `Camptocamp <https://www.camptocamp.com>`__:
125+
126+
- Cyril Jeanneret <cyril.jeanneret@camptocam.com>
127+
- Italo Lopes <italo.lopes@camptocam.com>
123128

124129
Other credits
125130
-------------

mail_composer_cc_bcc/models/ir_mail_server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class IrMailServer(models.Model):
1212
_inherit = "ir.mail_server"
1313

14-
def _prepare_email_message(self, message, smtp_session):
14+
def _prepare_email_message__(self, message, smtp_session):
1515
"""
1616
Define smtp_to based on context instead of To+Cc+Bcc
1717
"""
@@ -22,13 +22,13 @@ def _prepare_email_message(self, message, smtp_session):
2222
if x_odoo_bcc_value:
2323
message["Bcc"] = x_odoo_bcc_value
2424

25-
smtp_from, smtp_to_list, message = super()._prepare_email_message(
25+
smtp_from, smtp_to_list, message = super()._prepare_email_message__(
2626
message, smtp_session
2727
)
2828

2929
is_from_composer = self.env.context.get("is_from_composer", False)
30-
if is_from_composer and self.env.context.get("recipients", False):
31-
smtp_to = self.env.context["recipients"].pop(0)
30+
if is_from_composer and self.env.context.get("recipients_ids", False):
31+
smtp_to = self.env.context["recipients_ids"].pop(0)
3232
_logger.debug("smtp_to: %s", smtp_to)
3333
smtp_to_list = [smtp_to]
3434

mail_composer_cc_bcc/models/mail_mail.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ class MailMail(models.Model):
2525

2626
email_bcc = fields.Char("Bcc", help="Blind Cc message recipients")
2727

28-
# this method change on odoo 19.0
29-
# def _prepare_outgoing_list(self, mail_server=False, doc_to_followers=None):
30-
# TODO verify the code with the change doc_to_followers
31-
3228
def _prepare_outgoing_list(self, mail_server=False, doc_to_followers=None):
3329
# First, return if we're not coming from the Mail Composer
3430
res = super()._prepare_outgoing_list(
@@ -82,7 +78,7 @@ def _prepare_outgoing_list(self, mail_server=False, doc_to_followers=None):
8278
}
8379
)
8480

85-
self.env.context = {**self.env.context, "recipients": list(recipients)}
81+
self = self.with_context(recipients=list(recipients))
8682

8783
if len(res) > len(recipients):
8884
res.pop()

mail_composer_cc_bcc/models/mail_thread.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ def _get_message_create_valid_field_names(self):
2525
# NOTIFICATION API
2626
# ------------------------------------------------------
2727

28-
# this method change on odoo 19.0
29-
# def _notify_by_email_get_base_mail_values(self, message,
30-
# recipients_data, additional_values=None):
31-
# TODO verify the code with the change doc_to_followers
32-
3328
def _notify_by_email_get_base_mail_values(
3429
self, message, recipients_data, additional_values=None
3530
):
@@ -96,13 +91,12 @@ def _notify_get_recipients(self, message, msg_vals=False, **kwargs):
9691
pdata = {
9792
"id": data.get("id"),
9893
"active": data.get("active"),
99-
"share": data.get("share"),
10094
"notif": data.get("notif") and data.get("notif") or notif,
10195
"type": msg_type,
10296
"is_follower": data.get("is_follower"),
103-
"uid": False,
10497
}
105-
rdata.append(pdata)
98+
data.update(pdata)
99+
rdata.append(data)
106100
return rdata
107101

108102
def _notify_get_recipients_classify(
@@ -116,19 +110,15 @@ def _notify_get_recipients_classify(
116110
if not is_from_composer or skip_adding_cc_bcc:
117111
return res
118112
ids = []
119-
customer_data = None
113+
customer_data = []
120114
for rcpt_data in res:
121115
if rcpt_data["notification_group_name"] == "customer":
122-
customer_data = rcpt_data
123-
else:
124-
ids += rcpt_data["recipients"]
116+
customer_data.append(rcpt_data)
125117
if not customer_data:
126118
customer_data = res[0]
127119
customer_data["notification_group_name"] = "customer"
128-
customer_data["recipients"] = ids
129-
else:
130-
customer_data["recipients"] += ids
131-
return [customer_data]
120+
customer_data["recipients_ids"] = ids
121+
return customer_data
132122

133123
def _notify_thread(self, message, msg_vals=False, **kwargs):
134124
if message.message_type == "notification":

mail_composer_cc_bcc/readme/CONTRIBUTORS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@
55
> - Tri Doan \<<tridm@trobz.com>\>
66
77
* Alberto Nieto <alberto.nieto@braintec.com> (https://braintec.com)
8+
- [Camptocamp](https://www.camptocamp.com):
9+
10+
> - Cyril Jeanneret \<<cyril.jeanneret@camptocam.com>\>
11+
> - Italo Lopes \<<italo.lopes@camptocam.com>\>
12+

mail_composer_cc_bcc/static/description/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,14 @@ <h2>Contributors</h2>
456456
</li>
457457
<li><p class="first">Alberto Nieto <a class="reference external" href="mailto:alberto.nieto&#64;braintec.com">alberto.nieto&#64;braintec.com</a> (<a class="reference external" href="https://braintec.com">https://braintec.com</a>)</p>
458458
</li>
459+
<li><p class="first"><a class="reference external" href="https://www.camptocamp.com">Camptocamp</a>:</p>
460+
<blockquote>
461+
<ul class="simple">
462+
<li>Cyril Jeanneret &lt;<a class="reference external" href="mailto:cyril.jeanneret&#64;camptocam.com">cyril.jeanneret&#64;camptocam.com</a>&gt;</li>
463+
<li>Italo Lopes &lt;<a class="reference external" href="mailto:italo.lopes&#64;camptocam.com">italo.lopes&#64;camptocam.com</a>&gt;</li>
464+
</ul>
465+
</blockquote>
466+
</li>
459467
</ul>
460468
</div>
461469
<div class="section" id="other-credits">

0 commit comments

Comments
 (0)