Skip to content

Commit fab8ec7

Browse files
committed
[MIG] mail_environment: Migration to 19.0
1 parent dc16a6f commit fab8ec7

9 files changed

Lines changed: 213 additions & 124 deletions

File tree

mail_environment/README.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Mail configuration with server_environment
2121
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2222
:alt: License: AGPL-3
2323
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github
24-
:target: https://github.com/OCA/server-env/tree/18.0/mail_environment
24+
:target: https://github.com/OCA/server-env/tree/19.0/mail_environment
2525
:alt: OCA/server-env
2626
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/server-env-18-0/server-env-18-0-mail_environment
27+
:target: https://translation.odoo-community.org/projects/server-env-19-0/server-env-19-0-mail_environment
2828
:alt: Translate me on Weblate
2929
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30-
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-env&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-env&target_branch=19.0
3131
:alt: Try me on Runboat
3232

3333
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -103,16 +103,16 @@ file.
103103
Known issues / Roadmap
104104
======================
105105

106-
- Due to the special nature of this addon, you cannot test it on the OCA
107-
runbot.
106+
- Due to the special nature of this addon, you cannot test it on the
107+
OCA runbot.
108108

109109
Bug Tracker
110110
===========
111111

112112
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-env/issues>`_.
113113
In case of trouble, please check there if your issue has already been reported.
114114
If you spotted it first, help us to smash it by providing a detailed and welcomed
115-
`feedback <https://github.com/OCA/server-env/issues/new?body=module:%20mail_environment%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
115+
`feedback <https://github.com/OCA/server-env/issues/new?body=module:%20mail_environment%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
116116

117117
Do not contact contributors directly about support or help with technical issues.
118118

@@ -127,12 +127,12 @@ Authors
127127
Contributors
128128
------------
129129

130-
- Nicolas Bessi <nicolas.bessi@camptocamp.com>
131-
- Yannick Vaucher <yannick.vaucher@camptocamp.com>
132-
- Guewen Baconnier <guewen.baconnier@camptocamp.com>
133-
- Joël Grand-Guillaume <joel.grandguillaume@camptocamp.com>
134-
- Holger Brunn <hbrunn@therp.nl>
135-
- Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
130+
- Nicolas Bessi <nicolas.bessi@camptocamp.com>
131+
- Yannick Vaucher <yannick.vaucher@camptocamp.com>
132+
- Guewen Baconnier <guewen.baconnier@camptocamp.com>
133+
- Joël Grand-Guillaume <joel.grandguillaume@camptocamp.com>
134+
- Holger Brunn <hbrunn@therp.nl>
135+
- Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
136136

137137
Maintainers
138138
-----------
@@ -147,6 +147,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
147147
mission is to support the collaborative development of Odoo features and
148148
promote its widespread use.
149149

150-
This module is part of the `OCA/server-env <https://github.com/OCA/server-env/tree/18.0/mail_environment>`_ project on GitHub.
150+
This module is part of the `OCA/server-env <https://github.com/OCA/server-env/tree/19.0/mail_environment>`_ project on GitHub.
151151

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

mail_environment/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
{
55
"name": "Mail configuration with server_environment",
6-
"version": "18.0.1.0.1",
6+
"version": "19.0.1.0.0",
77
"category": "Tools",
88
"summary": "Configure mail servers with server_environment_files",
99
"author": "Camptocamp, Odoo Community Association (OCA)",

mail_environment/models/fetchmail_server.py

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# Copyright 2012-2018 Camptocamp SA
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
33

4-
import operator
5-
64
from odoo import api, fields, models
7-
from odoo.osv.expression import FALSE_DOMAIN
85

96

107
class FetchmailServer(models.Model):
@@ -40,31 +37,14 @@ def _server_env_global_section_name(self):
4037
"""
4138
return "incoming_mail"
4239

43-
@api.model
4440
def _search_is_ssl(self, oper, value):
45-
"""Keep the is_ssl field searchable to allow domain in search view."""
46-
if not isinstance(value, bool):
47-
return FALSE_DOMAIN
48-
operators = {
49-
"=": operator.eq,
50-
"!=": operator.ne,
51-
}
52-
if oper not in operators:
53-
return FALSE_DOMAIN
54-
servers = self.search([]).filtered(lambda s: operators[oper](value, s.is_ssl))
55-
return [("id", "in", servers.ids)]
41+
servers = self.search_fetch([], ["is_ssl"]).filtered_domain(
42+
[("is_ssl", oper, value)]
43+
)
44+
return fields.Domain([("id", "in", servers.ids)])
5645

57-
@api.model
5846
def _search_server_type(self, oper, value):
59-
operators = {
60-
"=": operator.eq,
61-
"!=": operator.ne,
62-
"in": operator.contains,
63-
"not in": lambda a, b: not operator.contains(a, b),
64-
}
65-
if oper not in operators:
66-
return [("id", "in", [])]
67-
servers = self.search([]).filtered(
68-
lambda s: operators[oper](value, s.server_type)
47+
servers = self.search_fetch([], ["server_type"]).filtered_domain(
48+
[("server_type", oper, value)]
6949
)
7050
return [("id", "in", servers.ids)]

mail_environment/models/ir_mail_server.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2012-2018 Camptocamp SA
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
33

4-
from odoo import api, models
4+
from odoo import api, fields, models
55

66

77
class IrMailServer(models.Model):
@@ -22,10 +22,18 @@ def _server_env_fields(self):
2222
mail_fields.update(base_fields)
2323
return mail_fields
2424

25+
smtp_user = fields.Char(search="_search_smtp_user")
26+
2527
@api.model
2628
def _server_env_global_section_name(self):
2729
"""Name of the global section in the configuration files
2830
2931
Can be customized in your model
3032
"""
3133
return "outgoing_mail"
34+
35+
def _search_smtp_user(self, oper, value):
36+
servers = self.search_fetch([], ["smtp_user"]).filtered_domain(
37+
[("smtp_user", oper, value)]
38+
)
39+
return fields.Domain([("id", "in", servers.ids)])

mail_environment/static/description/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ <h1>Mail configuration with server_environment</h1>
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375375
!! source digest: sha256:b27d3ac30fd7cb59d6eed6d0f910db100f70a145e028b2096015bcd7022a33b3
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-env/tree/18.0/mail_environment"><img alt="OCA/server-env" src="https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-env-18-0/server-env-18-0-mail_environment"><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/server-env&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-env/tree/19.0/mail_environment"><img alt="OCA/server-env" src="https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-env-19-0/server-env-19-0-mail_environment"><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/server-env&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378378
<p>This module allows to configure the incoming and outgoing mail servers
379379
using the server_environment mechanism: you can then have different mail
380380
servers for the production and the test environment.</p>
@@ -448,16 +448,16 @@ <h2><a class="toc-backref" href="#toc-entry-3">Usage</a></h2>
448448
<div class="section" id="known-issues-roadmap">
449449
<h2><a class="toc-backref" href="#toc-entry-4">Known issues / Roadmap</a></h2>
450450
<ul class="simple">
451-
<li>Due to the special nature of this addon, you cannot test it on the OCA
452-
runbot.</li>
451+
<li>Due to the special nature of this addon, you cannot test it on the
452+
OCA runbot.</li>
453453
</ul>
454454
</div>
455455
<div class="section" id="bug-tracker">
456456
<h2><a class="toc-backref" href="#toc-entry-5">Bug Tracker</a></h2>
457457
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-env/issues">GitHub Issues</a>.
458458
In case of trouble, please check there if your issue has already been reported.
459459
If you spotted it first, help us to smash it by providing a detailed and welcomed
460-
<a class="reference external" href="https://github.com/OCA/server-env/issues/new?body=module:%20mail_environment%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
460+
<a class="reference external" href="https://github.com/OCA/server-env/issues/new?body=module:%20mail_environment%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
461461
<p>Do not contact contributors directly about support or help with technical issues.</p>
462462
</div>
463463
<div class="section" id="credits">
@@ -488,7 +488,7 @@ <h3><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h3>
488488
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
489489
mission is to support the collaborative development of Odoo features and
490490
promote its widespread use.</p>
491-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-env/tree/18.0/mail_environment">OCA/server-env</a> project on GitHub.</p>
491+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-env/tree/19.0/mail_environment">OCA/server-env</a> project on GitHub.</p>
492492
<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>
493493
</div>
494494
</div>

mail_environment/tests/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
from . import test_mail_environment
1+
from . import test_incoming_mail
2+
from . import test_outgoing_mail
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Copyright 2018 Camptocamp (https://www.camptocamp.com).
2+
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
3+
4+
5+
from odoo.addons.server_environment.tests.common import ServerEnvironmentCase
6+
7+
fetchmail_config = """
8+
[incoming_mail.fetchmail1]
9+
server = safe_server
10+
port = 993
11+
server_type = imap
12+
is_ssl = 1
13+
attach = 1
14+
original = 1
15+
user = admin
16+
password = admin
17+
state = done
18+
priority = 1
19+
active = 1
20+
21+
[incoming_mail.fetchmail2]
22+
server = unsafe_server
23+
port = 143
24+
server_type = imap
25+
is_ssl = 0
26+
attach = 1
27+
original = 1
28+
user = admin
29+
password = admin
30+
state = done
31+
priority = 1
32+
active = 1
33+
"""
34+
35+
36+
class TestFetchMailEnvironment(ServerEnvironmentCase):
37+
@classmethod
38+
def setUpClass(cls):
39+
super().setUpClass()
40+
cls.FetchmailServer = cls.env["fetchmail.server"]
41+
cls.fetchmail1 = cls.FetchmailServer.create({"name": "fetchmail1"})
42+
cls.fetchmail2 = cls.FetchmailServer.create({"name": "fetchmail2"})
43+
44+
def test_fetchmail_search_is_ssl(self):
45+
with self.load_config(public=fetchmail_config):
46+
# Test basic properties
47+
self.assertTrue(self.fetchmail1.is_ssl)
48+
self.assertEqual(self.fetchmail1.port, 993)
49+
self.assertFalse(self.fetchmail2.is_ssl)
50+
self.assertEqual(self.fetchmail2.port, 143)
51+
52+
# Test is_ssl search method
53+
self.assertIn(
54+
self.fetchmail1,
55+
self.env["fetchmail.server"].search([("is_ssl", "=", True)]),
56+
)
57+
self.assertIn(
58+
self.fetchmail1,
59+
self.env["fetchmail.server"].search([("is_ssl", "!=", False)]),
60+
)
61+
self.assertNotIn(
62+
self.fetchmail1,
63+
self.env["fetchmail.server"].search([("is_ssl", "=", False)]),
64+
)
65+
self.assertNotIn(
66+
self.fetchmail1,
67+
self.env["fetchmail.server"].search([("is_ssl", "!=", True)]),
68+
)
69+
self.assertNotIn(
70+
self.fetchmail2,
71+
self.env["fetchmail.server"].search([("is_ssl", "=", True)]),
72+
)
73+
self.assertNotIn(
74+
self.fetchmail2,
75+
self.env["fetchmail.server"].search([("is_ssl", "!=", False)]),
76+
)
77+
self.assertIn(
78+
self.fetchmail2,
79+
self.env["fetchmail.server"].search([("is_ssl", "=", False)]),
80+
)
81+
self.assertIn(
82+
self.fetchmail2,
83+
self.env["fetchmail.server"].search([("is_ssl", "!=", True)]),
84+
)
85+
86+
def test_fetchmail_search_server_type(self):
87+
with self.load_config(public=fetchmail_config):
88+
# Test server_type search method
89+
self.assertIn(
90+
self.fetchmail1,
91+
self.env["fetchmail.server"].search([("server_type", "=", "imap")]),
92+
)
93+
self.assertIn(
94+
self.fetchmail1,
95+
self.env["fetchmail.server"].search([("server_type", "!=", "pop3")]),
96+
)
97+
self.assertNotIn(
98+
self.fetchmail1,
99+
self.env["fetchmail.server"].search([("server_type", "=", "pop3")]),
100+
)
101+
self.assertNotIn(
102+
self.fetchmail1,
103+
self.env["fetchmail.server"].search([("server_type", "!=", "imap")]),
104+
)
105+
self.assertIn(
106+
self.fetchmail1,
107+
self.env["fetchmail.server"].search(
108+
[("server_type", "=ilike", "IMAP")]
109+
),
110+
)
111+
self.assertIn(
112+
self.fetchmail1,
113+
self.env["fetchmail.server"].search([("server_type", "ilike", "IM")]),
114+
)
115+
self.assertNotIn(
116+
self.fetchmail1,
117+
self.env["fetchmail.server"].search([("server_type", "ilike", "POP")]),
118+
)

mail_environment/tests/test_mail_environment.py

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)