From 3d4cf03ca66386b70b81f1a81e10ec892e9d3b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 5 Jun 2023 11:57:42 +0000 Subject: [PATCH 1/2] [MOV] bus, mail: move and regroup some tests Purpose of this commit is to regroup some tests, or rename some too specific files in order to avoid explosion of files, making tests hard to find when looking for feature-specific tests. Task-3346388 Part-of: odoo/odoo#123678 --- .../tests/test_notify_security_update_totp.py | 2 +- addons/bus/tests/__init__.py | 1 + .../tests/test_ir_model.py} | 0 addons/mail/tests/__init__.py | 7 +++---- ...hatter_reload.py => test_mail_activity.py} | 2 +- addons/mail/tests/test_res_users.py | 21 +++++++++++++++++++ ...fy_security_update.py => test_security.py} | 0 .../tests/test_user_modify_own_profile.py | 20 ------------------ 8 files changed, 27 insertions(+), 26 deletions(-) rename addons/{mail/tests/test_get_model_definitions.py => bus/tests/test_ir_model.py} (100%) rename addons/mail/tests/{test_mail_chatter_reload.py => test_mail_activity.py} (93%) rename addons/mail/tests/{test_notify_security_update.py => test_security.py} (100%) delete mode 100644 addons/mail/tests/test_user_modify_own_profile.py diff --git a/addons/auth_totp_mail/tests/test_notify_security_update_totp.py b/addons/auth_totp_mail/tests/test_notify_security_update_totp.py index b72edf3e8ca..1d62ec3da78 100644 --- a/addons/auth_totp_mail/tests/test_notify_security_update_totp.py +++ b/addons/auth_totp_mail/tests/test_notify_security_update_totp.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo.addons.mail.tests.test_notify_security_update import TestNotifySecurityUpdate +from odoo.addons.mail.tests.test_security import TestNotifySecurityUpdate from odoo.tests import users diff --git a/addons/bus/tests/__init__.py b/addons/bus/tests/__init__.py index 4bab7610650..f8f91a9b5ef 100644 --- a/addons/bus/tests/__init__.py +++ b/addons/bus/tests/__init__.py @@ -1,6 +1,7 @@ from . import common from . import test_assetsbundle from . import test_health +from . import test_ir_model from . import test_ir_websocket from . import test_websocket_caryall from . import test_websocket_controller diff --git a/addons/mail/tests/test_get_model_definitions.py b/addons/bus/tests/test_ir_model.py similarity index 100% rename from addons/mail/tests/test_get_model_definitions.py rename to addons/bus/tests/test_ir_model.py diff --git a/addons/mail/tests/__init__.py b/addons/mail/tests/__init__.py index d6e2bd1eb3d..1f40f135c9c 100644 --- a/addons/mail/tests/__init__.py +++ b/addons/mail/tests/__init__.py @@ -1,18 +1,17 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import test_get_model_definitions from . import test_link_preview -from . import test_mail_chatter_reload +from . import test_mail_activity from . import test_mail_composer from . import test_mail_full_composer from . import test_mail_render from . import test_mail_template from . import test_mail_tools -from . import test_notify_security_update from . import test_res_partner from . import test_res_users from . import test_res_users_settings +from . import test_security from . import test_uninstall from . import test_update_notification -from . import test_user_modify_own_profile + from .discuss import * diff --git a/addons/mail/tests/test_mail_chatter_reload.py b/addons/mail/tests/test_mail_activity.py similarity index 93% rename from addons/mail/tests/test_mail_chatter_reload.py rename to addons/mail/tests/test_mail_activity.py index c6f27c756ae..c1d9c17bec0 100644 --- a/addons/mail/tests/test_mail_chatter_reload.py +++ b/addons/mail/tests/test_mail_activity.py @@ -4,7 +4,7 @@ from odoo.tests.common import tagged, HttpCase @tagged("-at_install", "post_install") -class TestMailChatterReload(HttpCase): +class TestMailActivityChatter(HttpCase): def test_chatter_activity_tour(self): testuser = self.env['res.users'].create({ diff --git a/addons/mail/tests/test_res_users.py b/addons/mail/tests/test_res_users.py index c129c0b2f01..849b4a0933f 100644 --- a/addons/mail/tests/test_res_users.py +++ b/addons/mail/tests/test_res_users.py @@ -2,9 +2,12 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from psycopg2 import IntegrityError +from unittest.mock import patch from odoo import Command +from odoo.addons.base.models.res_users import Users from odoo.addons.mail.tests.common import MailCommon, mail_new_test_user +from odoo.tests import HttpCase, tagged from odoo.tools import mute_logger @@ -45,3 +48,21 @@ class TestUser(MailCommon): ]}) self.assertEqual(user.notification_type, 'email') self.assertNotIn(self.env.ref('mail.group_mail_notification_type_inbox'), user.groups_id) + + +@tagged('-at_install', 'post_install') +class TestUserModifyOwnProfile(HttpCase): + + def test_user_modify_own_profile(self): + """" A user should be able to modify their own profile. + Even if that user does not have access rights to write on the res.users model. """ + + # avoid 'reload_context' action in the middle of the tour to ease steps and form save checks + with patch.object(Users, 'preference_save', lambda self: True): + self.start_tour( + "/web", + "mail/static/tests/tours/user_modify_own_profile_tour.js", + login="demo", + step_delay=100, + ) + self.assertEqual(self.env.ref('base.user_demo').email, "updatedemail@example.com") diff --git a/addons/mail/tests/test_notify_security_update.py b/addons/mail/tests/test_security.py similarity index 100% rename from addons/mail/tests/test_notify_security_update.py rename to addons/mail/tests/test_security.py diff --git a/addons/mail/tests/test_user_modify_own_profile.py b/addons/mail/tests/test_user_modify_own_profile.py deleted file mode 100644 index 40b6f245df4..00000000000 --- a/addons/mail/tests/test_user_modify_own_profile.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo.tests import HttpCase, tagged -from odoo.addons.base.models.res_users import Users - -from unittest.mock import patch - - -@tagged('-at_install', 'post_install') -class TestUserModifyOwnProfile(HttpCase): - - def test_user_modify_own_profile(self): - """" A user should be able to modify their own profile. - Even if that user does not have access rights to write on the res.users model. """ - - # avoid 'reload_context' action in the middle of the tour to ease steps and form save checks - with patch.object(Users, 'preference_save', lambda self: True): - self.start_tour("/web", "mail/static/tests/tours/user_modify_own_profile_tour.js", login="demo", step_delay=100) - self.assertEqual(self.env.ref('base.user_demo').email, "updatedemail@example.com") From 50762307e45737161050f6ea0973190599fa1813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 5 Jun 2023 10:45:52 +0000 Subject: [PATCH 2/2] [IMP] base, mail: split company email colors from document colors PURPOSE Settings allow to change colors used in emails (primary and secondary colors). Those are used for headers and buttons. They are currently shared with colors used for base documents and reports layout: changing email colors change documents colors, which is not expected nor clearly indicated. SPECIFICATIONS Split configuration: colors used in documents may differ from colors used in emails. Duplicate color fields (primary and secondary). To ease setup when updating documents colors, update mail colors accordingly. Inverse is not true as we consider documents being the main configuration, and emails a more fine-grain configuration. Task-3346388 Part-of: odoo/odoo#123678 --- addons/digest/data/digest_data.xml | 4 +- addons/mail/__manifest__.py | 2 +- .../data/mail_templates_email_layouts.xml | 10 ++-- addons/mail/models/res_company.py | 27 +++++++++- addons/mail/models/res_config_settings.py | 4 +- addons/mail/tests/__init__.py | 1 + addons/mail/tests/test_res_company.py | 52 +++++++++++++++++++ .../mail/views/res_config_settings_views.xml | 4 +- .../data/mailing_data_templates.xml | 2 +- 9 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 addons/mail/tests/test_res_company.py diff --git a/addons/digest/data/digest_data.xml b/addons/digest/data/digest_data.xml index eec141479cc..5f8b2c16820 100644 --- a/addons/digest/data/digest_data.xml +++ b/addons/digest/data/digest_data.xml @@ -11,7 +11,7 @@