Files
odoo_source/addons/mail/models/__init__.py
T
Pierre-Yves Dufays ac67e6a8df [IMP] base,{fetch}mail,l10n_it_edi,{test}mass_mailing:prevent using arch server
Prevent archiving in-use mail servers by displaying an error message that
lists where it is still used, allowing to easily identify what need to be
updated before being able to archive the mail server.

Additionally,
- prevent the use of archived server as a fall-safe
- when duplicating a mailing with an archived mail server, replace mail
server by the default one

Detailed explanation:
1. A check has been added that raise an exception when trying to connect to the
smtp server or send an email when the server is archived.
With that solution,
- testing the connection of an archived server displays an error telling that
an archived server cannot be used.
- if a mail is still sent with an archived server, mail are in error :
"Connection failed (outgoing mail server problem)"
This fail-safe ensures that no mail will be sent through an archived mail server
and that the user will get some feedback about it.

The same fail-safe for the incoming mail server has been added.

Notes:
- the connection will outlive the archiving of a mail server still allowing
to send email through the archived server until the connection is closed. But
connection are not kept for long so this shouldn't be a problem.
- it cannot be tested because the connect method return immediately in test
mode.

2. When a mail server is archived, an user error is raised if it is in-use.
The implementation relies on each module to override the method
"_active_usages_compute" in "ir_mail_server" to complete the list with
user-friendly message describing the active elements that could send mail
through the mail server. This has been implemented for:
- l10n_it_edi: server used to send e-invoice
- mail: optional server configured for template
- mass_mailing:
-- default mail server
-- active server configured for mailing

Mail server are referenced in other elements but are not active anymore, it is
just for temporary or history purpose. Those references doesn’t prevent the
archiving of the mail server:
- mail_message
- wizard survey_invite and compose_message
- res_config_settings

Task-2821516

closes odoo/odoo#91240

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-09-01 15:32:44 +02:00

64 lines
1.7 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
# core models (required for mixins)
from . import mail_alias
from . import models
# mixin
from . import mail_activity_mixin
from . import mail_alias_mixin
from . import mail_render_mixin
from . import mail_composer_mixin
from . import mail_thread
from . import mail_thread_blacklist
from . import mail_thread_cc
from . import template_reset_mixin
# mail models
from . import fetchmail
from . import mail_notification # keep before as decorated m2m
from . import mail_activity_type
from . import mail_activity
from . import mail_blacklist
from . import mail_followers
from . import mail_gateway_allowed
from . import mail_message_reaction
from . import mail_message_schedule
from . import mail_message_subtype
from . import mail_message
from . import mail_mail
from . import mail_tracking_value
from . import mail_template
# discuss
from . import mail_channel_member
from . import mail_channel_rtc_session
from . import mail_channel
from . import mail_guest
from . import mail_ice_server
from . import mail_shortcode
from . import res_users_settings
from . import res_users_settings_volumes
# odoo models
from . import bus_presence
from . import ir_action_act_window
from . import ir_actions_server
from . import ir_attachment
from . import ir_config_parameter
from . import ir_http
from . import ir_mail_server
from . import ir_model
from . import ir_model_fields
from . import ir_translation
from . import ir_ui_view
from . import ir_qweb
from . import ir_websocket
from . import res_company
from . import res_config_settings
from . import res_partner
from . import res_users
from . import res_groups
from . import update