Skip to content

Commit

Permalink
[FIX] account: log error in chatter when importing xml
Browse files Browse the repository at this point in the history
Before c02d8b1, an error occuring
during the import was logged in the chatter. We now log the error in the
application logs.

For instance: opw-3874857
  • Loading branch information
JulienVR committed May 14, 2024
1 parent 4b8b1ac commit c65a13b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion addons/account/i18n/account.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6040,7 +6040,9 @@ msgstr ""
#. odoo-python
#: code:addons/account/models/account_move.py:0
#, python-format
msgid "Error importing attachment '%s' as invoice (decoder=%s)"
msgid ""
"Error importing attachment '%s' as invoice (decoder=%s). Check the file "
"itself, or read the application logs for more information."
msgstr ""

#. module: account
Expand Down
17 changes: 13 additions & 4 deletions addons/account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -3183,10 +3183,19 @@ def add_file_data_results(file_data, invoice):

except RedirectWarning:
raise
except Exception:
message = _("Error importing attachment '%s' as invoice (decoder=%s)", file_data['filename'], decoder.__name__)
invoice.sudo().message_post(body=message)
_logger.exception(message)
except Exception as e:
invoice.sudo().message_post(body=_(
"Error importing attachment '%s' as invoice (decoder=%s). Check the file itself, or read the "
"application logs for more information.",
file_data['filename'],
decoder.__name__,
))
_logger.exception(
"Error importing attachment '%s' as invoice (decoder=%s): %s",
file_data['filename'],
decoder.__name__,
str(e),
)

passed_file_data_list.append(file_data)
close_file(file_data)
Expand Down

0 comments on commit c65a13b

Please sign in to comment.