Skip to content

Commit 4bbed15

Browse files
committed
[MIG] mail_server_by_user: Migration to 16.0
1 parent 89fb261 commit 4bbed15

File tree

8 files changed

+55
-40
lines changed

8 files changed

+55
-40
lines changed

mail_server_by_user/README.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Email Server By User
1717
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
1818
:alt: License: LGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
20-
:target: https://github.com/OCA/social/tree/14.0/mail_server_by_user
20+
:target: https://github.com/OCA/social/tree/16.0/mail_server_by_user
2121
:alt: OCA/social
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/social-14-0/social-14-0-mail_server_by_user
23+
:target: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_server_by_user
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=14.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=16.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -47,7 +47,7 @@ Bug Tracker
4747
Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
4848
In case of trouble, please check there if your issue has already been reported.
4949
If you spotted it first, help us to smash it by providing a detailed and welcomed
50-
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_server_by_user%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
50+
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_server_by_user%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
5151

5252
Do not contact contributors directly about support or help with technical issues.
5353

@@ -63,6 +63,7 @@ Contributors
6363
~~~~~~~~~~~~
6464

6565
* Christopher Ormaza <[email protected]>
66+
* `Onestein <https://www.onestein.eu>`__
6667

6768
Maintainers
6869
~~~~~~~~~~~
@@ -85,6 +86,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
8586

8687
|maintainer-ChrisOForgeFlow|
8788

88-
This module is part of the `OCA/social <https://github.com/OCA/social/tree/14.0/mail_server_by_user>`_ project on GitHub.
89+
This module is part of the `OCA/social <https://github.com/OCA/social/tree/16.0/mail_server_by_user>`_ project on GitHub.
8990

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

mail_server_by_user/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Email Server By User",
66
"summary": "Email Server By User",
7-
"version": "14.0.1.0.0",
7+
"version": "16.0.1.0.0",
88
"category": "Social Network",
99
"website": "https://github.com/OCA/social",
1010
"author": ("ForgeFlow, " "Odoo Community Association (OCA)"),

mail_server_by_user/models/ir_mail_server.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
class IrMailServer(models.Model):
8-
98
_inherit = "ir.mail_server"
109

1110
@api.model
@@ -18,6 +17,8 @@ def send_email(
1817
smtp_user=None,
1918
smtp_password=None,
2019
smtp_encryption=None,
20+
smtp_ssl_certificate=None,
21+
smtp_ssl_private_key=None,
2122
smtp_debug=False,
2223
smtp_session=None,
2324
):
@@ -36,6 +37,8 @@ def send_email(
3637
smtp_user,
3738
smtp_password,
3839
smtp_encryption,
40+
smtp_ssl_certificate,
41+
smtp_ssl_private_key,
3942
smtp_debug,
4043
smtp_session,
4144
)

mail_server_by_user/models/mail_mail.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
class MailMail(models.Model):
8-
98
_inherit = "mail.mail"
109

1110
def _send(self, auto_commit=False, raise_exception=False, smtp_session=None):

mail_server_by_user/models/mail_thread.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@
66

77

88
class MailThread(models.AbstractModel):
9-
109
_inherit = "mail.thread"
1110

12-
def _notify_record_by_email(
11+
def _notify_thread_by_email(
1312
self,
1413
message,
1514
recipients_data,
1615
msg_vals=False,
17-
model_description=False,
1816
mail_auto_delete=True,
19-
check_existing=False,
17+
model_description=False,
18+
force_email_company=False,
19+
force_email_lang=False,
20+
resend_existing=False,
2021
force_send=True,
2122
send_after_commit=True,
23+
subtitles=None,
2224
**kwargs
2325
):
2426
mail_server_model = self.env["ir.mail_server"].sudo()
@@ -31,14 +33,17 @@ def _notify_record_by_email(
3133
and message.mail_server_id.id != mail_server_suggested.id
3234
):
3335
message.mail_server_id = mail_server_suggested.id
34-
return super(MailThread, self)._notify_record_by_email(
36+
return super(MailThread, self)._notify_thread_by_email(
3537
message,
3638
recipients_data,
3739
msg_vals,
38-
model_description,
3940
mail_auto_delete,
40-
check_existing,
41+
model_description,
42+
force_email_company,
43+
force_email_lang,
44+
resend_existing,
4145
force_send,
4246
send_after_commit,
47+
subtitles,
4348
**kwargs
4449
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* Christopher Ormaza <[email protected]>
2+
* `Onestein <https://www.onestein.eu>`__

mail_server_by_user/static/description/index.html

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
43
<head>
@@ -9,10 +8,11 @@
98

109
/*
1110
:Author: David Goodger ([email protected])
12-
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
11+
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
1312
:Copyright: This stylesheet has been placed in the public domain.
1413
1514
Default cascading style sheet for the HTML output of Docutils.
15+
Despite the name, some widely supported CSS2 features are used.
1616
1717
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1818
customize this style sheet.
@@ -275,7 +275,7 @@
275275
margin-left: 2em ;
276276
margin-right: 2em }
277277

278-
pre.code .ln { color: grey; } /* line numbers */
278+
pre.code .ln { color: gray; } /* line numbers */
279279
pre.code, code { background-color: #eeeeee }
280280
pre.code .comment, code .comment { color: #5C6576 }
281281
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +301,7 @@
301301
span.pre {
302302
white-space: pre }
303303

304-
span.problematic {
304+
span.problematic, pre.problematic {
305305
color: red }
306306

307307
span.section-subtitle {
@@ -369,7 +369,7 @@ <h1 class="title">Email Server By User</h1>
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370370
!! source digest: sha256:9313575d1d36133e0993e203d53247a3beb4122f34e111c8418dfb07f57733c8
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<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/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/social/tree/14.0/mail_server_by_user"><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-14-0/social-14-0-mail_server_by_user"><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=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<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/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/social/tree/16.0/mail_server_by_user"><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_server_by_user"><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>
373373
<p>Change SMTP server with smtp_user equal email of
374374
user perform mail actions, like message_post, mail.mail send, and base email sending</p>
375375
<div class="admonition important">
@@ -395,7 +395,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
395395
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
396396
In case of trouble, please check there if your issue has already been reported.
397397
If you spotted it first, help us to smash it by providing a detailed and welcomed
398-
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_server_by_user%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
398+
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_server_by_user%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
399399
<p>Do not contact contributors directly about support or help with technical issues.</p>
400400
</div>
401401
<div class="section" id="credits">
@@ -410,18 +410,21 @@ <h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
410410
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
411411
<ul class="simple">
412412
<li>Christopher Ormaza &lt;<a class="reference external" href="mailto:chris.ormaza&#64;forgeflow.com">chris.ormaza&#64;forgeflow.com</a>&gt;</li>
413+
<li><a class="reference external" href="https://www.onestein.eu">Onestein</a></li>
413414
</ul>
414415
</div>
415416
<div class="section" id="maintainers">
416417
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
417418
<p>This module is maintained by the OCA.</p>
418-
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
419+
<a class="reference external image-reference" href="https://odoo-community.org">
420+
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
421+
</a>
419422
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
420423
mission is to support the collaborative development of Odoo features and
421424
promote its widespread use.</p>
422425
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
423426
<p><a class="reference external image-reference" href="https://github.com/ChrisOForgeFlow"><img alt="ChrisOForgeFlow" src="https://github.com/ChrisOForgeFlow.png?size=40px" /></a></p>
424-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/14.0/mail_server_by_user">OCA/social</a> project on GitHub.</p>
427+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/16.0/mail_server_by_user">OCA/social</a> project on GitHub.</p>
425428
<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>
426429
</div>
427430
</div>

mail_server_by_user/tests/test_mail_server_by_user.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# Copyright 2022 ForgeFlow S.L.
22
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3-
3+
import logging
44
import os
5-
import threading
65
from email import message_from_string
7-
8-
from mock import MagicMock
6+
from unittest.mock import MagicMock
97

108
from odoo import _
119
from odoo.tests.common import TransactionCase
1210

11+
_logger = logging.getLogger(__name__)
12+
1313

1414
class TestIrMailServer(TransactionCase):
1515
def setUp(self):
1616
super(TestIrMailServer, self).setUp()
1717
self.smtp_server_model = self.env["ir.mail_server"]
1818
self.parameter_model = self.env["ir.config_parameter"]
19-
self.default_template = self.env.ref("mail.message_notification_email")
20-
self.paynow_template = self.env.ref("mail.mail_notification_paynow")
19+
# self.default_template = self.env.ref("mail.message_notification_email")
20+
# self.paynow_template = self.env.ref("mail.mail_notification_paynow")
2121
self.server_1 = self.smtp_server_model.create(
2222
{
2323
"name": "localhost",
@@ -95,16 +95,13 @@ def _send_mail(self, message=None, mail_server_id=None, smtp_server=None):
9595
if message is None:
9696
message = self.message
9797
connect = MagicMock()
98-
thread = threading.currentThread()
99-
thread.testing = False
98+
self.smtp_server_model._patch_method("connect", connect)
10099
try:
101-
self.smtp_server_model._patch_method("connect", connect)
102-
try:
103-
self.smtp_server_model.send_email(message, mail_server_id, smtp_server)
104-
finally:
105-
self.smtp_server_model._revert_method("connect")
100+
self.smtp_server_model.send_email(message, mail_server_id, smtp_server)
101+
except Exception as e:
102+
_logger.debug(str(e))
106103
finally:
107-
thread.testing = True
104+
self.smtp_server_model._revert_method("connect")
108105
call_args = connect.call_args
109106
return call_args
110107

@@ -131,15 +128,21 @@ def test_send_email_change_smtp_server(self):
131128

132129
def test_message_thread_send(self):
133130
mail_message_1 = self.partner.with_user(self.user1).message_post(
134-
body=_("Test"), subtype_xmlid="mail.mt_comment"
131+
body=_("Test"),
132+
subtype_xmlid="mail.mt_comment",
133+
partner_ids=self.partner.ids,
135134
)
136135
self.assertEqual(mail_message_1.mail_server_id.id, self.server_1.id)
137136
mail_message_2 = self.partner.with_user(self.user2).message_post(
138-
body=_("Test"), subtype_xmlid="mail.mt_comment"
137+
body=_("Test"),
138+
subtype_xmlid="mail.mt_comment",
139+
partner_ids=self.partner.ids,
139140
)
140141
self.assertEqual(mail_message_2.mail_server_id.id, self.server_2.id)
141142
mail_message_3 = self.partner.with_user(self.user3).message_post(
142-
body=_("Test"), subtype_xmlid="mail.mt_comment"
143+
body=_("Test"),
144+
subtype_xmlid="mail.mt_comment",
145+
partner_ids=self.partner.ids,
143146
)
144147
self.assertFalse(mail_message_3.mail_server_id.id)
145148

0 commit comments

Comments
 (0)