diff --git a/account_bank_statement_import_online/__manifest__.py b/account_bank_statement_import_online/__manifest__.py index c614dd47..4a7ed9a5 100644 --- a/account_bank_statement_import_online/__manifest__.py +++ b/account_bank_statement_import_online/__manifest__.py @@ -4,7 +4,7 @@ { 'name': 'Online Bank Statements', - 'version': '12.0.1.0.0', + 'version': '12.0.1.0.1', 'author': 'Brainbean Apps, ' 'Dataplug, ' diff --git a/account_bank_statement_import_online/i18n/account_bank_statement_import_online.pot b/account_bank_statement_import_online/i18n/account_bank_statement_import_online.pot index 3d9d353f..3fe107c3 100644 --- a/account_bank_statement_import_online/i18n/account_bank_statement_import_online.pot +++ b/account_bank_statement_import_online/i18n/account_bank_statement_import_online.pot @@ -14,7 +14,7 @@ msgstr "" "Plural-Forms: \n" #. module: account_bank_statement_import_online -#: code:addons/account_bank_statement_import_online/models/online_bank_statement_provider.py:140 +#: code:addons/account_bank_statement_import_online/models/online_bank_statement_provider.py:141 #, python-format msgid "%(number)s %(type)s" msgstr "" @@ -164,7 +164,7 @@ msgid "If checked, some messages have a delivery error." msgstr "" #. module: account_bank_statement_import_online -#: code:addons/account_bank_statement_import_online/models/online_bank_statement_provider.py:137 +#: code:addons/account_bank_statement_import_online/models/online_bank_statement_provider.py:138 #: model_terms:ir.ui.view,arch_db:account_bank_statement_import_online.online_bank_statement_provider_filter #, python-format msgid "Inactive" @@ -239,6 +239,12 @@ msgstr "" msgid "Monthly statements" msgstr "" +#. module: account_bank_statement_import_online +#: code:addons/account_bank_statement_import_online/models/online_bank_statement_provider.py:191 +#, python-format +msgid "N/A" +msgstr "" + #. module: account_bank_statement_import_online #: model:ir.model.fields,field_description:account_bank_statement_import_online.field_online_bank_statement_provider__name msgid "Name" @@ -288,14 +294,14 @@ msgid "Online Bank Statement Provider" msgstr "" #. module: account_bank_statement_import_online -#: code:addons/account_bank_statement_import_online/models/online_bank_statement_provider.py:182 +#: code:addons/account_bank_statement_import_online/models/online_bank_statement_provider.py:184 #, python-format msgid "Online Bank Statement Provider \"%s\" failed to obtain statement data since %s until %s:\n" "%s" msgstr "" #. module: account_bank_statement_import_online -#: code:addons/account_bank_statement_import_online/models/online_bank_statement_provider.py:191 +#: code:addons/account_bank_statement_import_online/models/online_bank_statement_provider.py:193 #, python-format msgid "Online Bank Statement Provider failure" msgstr "" diff --git a/account_bank_statement_import_online/models/online_bank_statement_provider.py b/account_bank_statement_import_online/models/online_bank_statement_provider.py index 6efb8343..41001f3a 100644 --- a/account_bank_statement_import_online/models/online_bank_statement_provider.py +++ b/account_bank_statement_import_online/models/online_bank_statement_provider.py @@ -1,10 +1,11 @@ -# Copyright 2019 Brainbean Apps (https://brainbeanapps.com) -# Copyright 2019 Dataplug (https://dataplug.io) +# Copyright 2019-2020 Brainbean Apps (https://brainbeanapps.com) +# Copyright 2019-2020 Dataplug (https://dataplug.io) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from dateutil.relativedelta import relativedelta, MO from decimal import Decimal import logging +from sys import exc_info from odoo import models, fields, api, _ from odoo.addons.base.models.res_bank import sanitize_account_number @@ -167,7 +168,8 @@ class OnlineBankStatementProvider(models.Model): statement_date_since, statement_date_until ) - except Exception as e: + except: + e = exc_info()[1] if is_scheduled: _logger.warning( 'Online Bank Statement Provider "%s" failed to' @@ -186,7 +188,7 @@ class OnlineBankStatementProvider(models.Model): provider.name, statement_date_since, statement_date_until, - str(e), + str(e) if e else _('N/A'), ), subject=_( 'Online Bank Statement Provider failure' diff --git a/account_bank_statement_import_online/tests/online_bank_statement_provider_dummy.py b/account_bank_statement_import_online/tests/online_bank_statement_provider_dummy.py index 04b96ca1..6c3f0870 100644 --- a/account_bank_statement_import_online/tests/online_bank_statement_provider_dummy.py +++ b/account_bank_statement_import_online/tests/online_bank_statement_provider_dummy.py @@ -1,5 +1,5 @@ -# Copyright 2019 Brainbean Apps (https://brainbeanapps.com) -# Copyright 2019 Dataplug (https://dataplug.io) +# Copyright 2019-2020 Brainbean Apps (https://brainbeanapps.com) +# Copyright 2019-2020 Dataplug (https://dataplug.io) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from datetime import datetime, timedelta @@ -22,7 +22,11 @@ class OnlineBankStatementProviderDummy(models.Model): ) # pragma: no cover if self.env.context.get('crash', False): - raise Exception('Expected') + exception = self.env.context.get( + 'exception', + Exception('Expected') + ) + raise exception line_step_options = self.env.context.get('step', { 'minutes': 5, diff --git a/account_bank_statement_import_online/tests/test_account_bank_statement_import_online.py b/account_bank_statement_import_online/tests/test_account_bank_statement_import_online.py index 2eb25d19..00be08f3 100644 --- a/account_bank_statement_import_online/tests/test_account_bank_statement_import_online.py +++ b/account_bank_statement_import_online/tests/test_account_bank_statement_import_online.py @@ -1,10 +1,10 @@ -# Copyright 2019 Brainbean Apps (https://brainbeanapps.com) -# Copyright 2019 Dataplug (https://dataplug.io) +# Copyright 2019-2020 Brainbean Apps (https://brainbeanapps.com) +# Copyright 2019-2020 Dataplug (https://dataplug.io) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from dateutil.relativedelta import relativedelta - from psycopg2 import IntegrityError +from urllib.error import HTTPError from odoo.tests import common from odoo.tools import mute_logger @@ -341,3 +341,25 @@ class TestAccountBankAccountStatementImportOnline(common.TransactionCase): self.now - relativedelta(hours=1), self.now, ) + + def test_pull_httperror(self): + journal = self.AccountJournal.create({ + 'name': 'Bank', + 'type': 'bank', + 'code': 'BANK', + 'bank_statements_source': 'online', + 'online_bank_statement_provider': 'dummy', + }) + + provider = journal.online_bank_statement_provider_id + provider.active = True + provider.statement_creation_mode = 'weekly' + + with self.assertRaises(HTTPError): + provider.with_context( + crash=True, + exception=HTTPError(None, 500, 'Error', None, None), + )._pull( + self.now - relativedelta(hours=1), + self.now, + )