From 8ea268e90c556a56027cdfa1b7e62891c7d69b32 Mon Sep 17 00:00:00 2001 From: Tom Date: Thu, 9 Jan 2025 10:56:35 +0100 Subject: [PATCH] [FIX] fetchmail_attach_from_folder: be able to open form view even when connection fails Background: on Outlook servers and possibly on other providers as well, connect can fail with a UserError. Before this fix this results in the form view not being able to open because the compute cannot complete. This fixes that, so that the connection error may be resolved by the user. --- fetchmail_attach_from_folder/models/fetchmail_server.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fetchmail_attach_from_folder/models/fetchmail_server.py b/fetchmail_attach_from_folder/models/fetchmail_server.py index 7d344395ab4..5c973e4827e 100644 --- a/fetchmail_attach_from_folder/models/fetchmail_server.py +++ b/fetchmail_attach_from_folder/models/fetchmail_server.py @@ -4,6 +4,7 @@ import re from odoo import _, api, fields, models +from odoo.exceptions import UserError _logger = logging.getLogger(__name__) @@ -30,7 +31,11 @@ def parse_list_response(line): if this.state != "done": this.folders_available = _("Confirm connection first.") continue - connection = this.connect() + try: + connection = this.connect() + except UserError: + this.folders_available = _("Confirm connection first.") + continue list_result = connection.list() if list_result[0] != "OK": this.folders_available = _("Unable to retrieve folders.")