[FIX] account_bank_statement_import_online: catch any exception

[UPD] Update account_bank_statement_import_online.pot

account_bank_statement_import_online 12.0.1.0.1
This commit is contained in:
Alexey Pelykh
2020-03-23 08:14:37 +01:00
committed by Ronald Portier
parent ff2dd80b96
commit 81a6106e31
5 changed files with 49 additions and 15 deletions

View File

@@ -4,7 +4,7 @@
{
'name': 'Online Bank Statements',
'version': '12.0.1.0.0',
'version': '12.0.1.0.1',
'author':
'Brainbean Apps, '
'Dataplug, '

View File

@@ -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 ""

View File

@@ -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'

View File

@@ -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,

View File

@@ -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,
)