Skip to content

Commit

Permalink
[FIX] fetchmail_attach_from_folder: be able to open form view even wh…
Browse files Browse the repository at this point in the history
…en 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.
  • Loading branch information
thomaspaulb committed Jan 9, 2025
1 parent 961688e commit 8ea268e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fetchmail_attach_from_folder/models/fetchmail_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import re

from odoo import _, api, fields, models
from odoo.exceptions import UserError

_logger = logging.getLogger(__name__)

Expand All @@ -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

Check warning on line 38 in fetchmail_attach_from_folder/models/fetchmail_server.py

View check run for this annotation

Codecov / codecov/patch

fetchmail_attach_from_folder/models/fetchmail_server.py#L34-L38

Added lines #L34 - L38 were not covered by tests
list_result = connection.list()
if list_result[0] != "OK":
this.folders_available = _("Unable to retrieve folders.")
Expand Down

0 comments on commit 8ea268e

Please sign in to comment.