Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion fetchmail_attach_from_folder/models/fetchmail_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ def fetch_mail(self, **kwargs):
result = True
for this in self:
if not this.folders_only:
result = result and super(FetchmailServer, this).fetch_mail(**kwargs)
# In Odoo 18, fetch_mail accepts raise_exception parameter
# Don't pass it unless explicitly provided
super_kwargs = {
k: v for k, v in kwargs.items() if k != "raise_exception"
}
result = result and super(FetchmailServer, this).fetch_mail(
**super_kwargs
)
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raise_exception is being stripped unconditionally before calling super().fetch_mail(). On Odoo versions where the parent method does support raise_exception, this will ignore the caller’s intent (e.g., Odoo 18 cron passes raise_exception=False) and can change behavior by falling back to the parent default. Consider forwarding raise_exception when supported and only dropping it for older parents (e.g., call super().fetch_mail(**kwargs) and, if a TypeError for an unexpected keyword is raised, retry after removing raise_exception). Also the inline comment says “Don’t pass it unless explicitly provided”, but the current code never passes it even when explicitly provided.

Suggested change
# In Odoo 18, fetch_mail accepts raise_exception parameter
# Don't pass it unless explicitly provided
super_kwargs = {
k: v for k, v in kwargs.items() if k != "raise_exception"
}
result = result and super(FetchmailServer, this).fetch_mail(
**super_kwargs
)
# Forward kwargs as-is so supported parent implementations
# honor the caller's raise_exception value. Fall back for
# older versions that don't accept that keyword.
try:
result = result and super(FetchmailServer, this).fetch_mail(
**kwargs
)
except TypeError as err:
if (
"raise_exception" not in kwargs
or "raise_exception" not in str(err)
or "unexpected keyword" not in str(err)
):
raise
super_kwargs = {
k: v for k, v in kwargs.items() if k != "raise_exception"
}
result = result and super(FetchmailServer, this).fetch_mail(
**super_kwargs
)

Copilot uses AI. Check for mistakes.
this.folder_ids.fetch_mail()
return result
Loading