[MIG] account_bank_statement_import_online_paypal: Migration to 15.0

This commit is contained in:
ikapasi
2022-05-25 09:54:00 +05:30
committed by Miquel Raïch
parent eb7c246844
commit 3664c9dd66
4 changed files with 27 additions and 10 deletions

View File

@@ -4,7 +4,7 @@
{
"name": "Online Bank Statements: PayPal.com",
"version": "14.0.1.0.0",
"version": "15.0.1.0.0",
"author": "CorporateHub, Odoo Community Association (OCA)",
"maintainers": ["alexey-pelykh"],
"website": "https://github.com/OCA/bank-statement-import",

View File

@@ -230,8 +230,12 @@ class OnlineBankStatementProviderPayPal(models.Model):
)
if not first_transaction:
raise UserError(
_("Failed to resolve transaction %s (%s)")
% (first_transaction_id, first_transaction_date)
_(
"Failed to resolve transaction %(first_transaction_id)s "
"(%(first_transaction_date)s)",
first_transaction_id=first_transaction_id,
first_transaction_date=first_transaction_date,
)
)
balance_start = self._paypal_get_transaction_ending_balance(first_transaction)
balance_start -= self._paypal_get_transaction_total_amount(first_transaction)
@@ -245,8 +249,12 @@ class OnlineBankStatementProviderPayPal(models.Model):
)
if not last_transaction:
raise UserError(
_("Failed to resolve transaction %s (%s)")
% (last_transaction_id, last_transaction_date)
_(
"Failed to resolve transaction %(last_transaction_id)s "
"(%(last_transaction_date)s)",
last_transaction_id=last_transaction_id,
last_transaction_date=last_transaction_date,
)
)
balance_end = self._paypal_get_transaction_ending_balance(last_transaction)
@@ -496,7 +504,7 @@ class OnlineBankStatementProviderPayPal(models.Model):
"total_pages": 0,
}
raise self._paypal_decode_error(content) or e
raise self._paypal_decode_error(content) or e from None
return json.loads(content)
@api.model

View File

@@ -2,3 +2,4 @@
* Alexey Pelykh <alexey.pelykh@corphub.eu>
* Omar Castiñeira <omar@comunitea.com>
* isufi kapasi <isufi.kapasi@initos.com>

View File

@@ -144,7 +144,9 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
_provider_class + "._paypal_retrieve",
return_value=mocked_response,
):
with self.assertRaises(Exception):
with self.assertRaisesRegex(
UserError, "PayPal App features are configured incorrectly!"
):
provider._paypal_get_token()
def test_bad_token_type(self):
@@ -175,7 +177,7 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
_provider_class + "._paypal_retrieve",
return_value=mocked_response,
):
with self.assertRaises(Exception):
with self.assertRaisesRegex(UserError, "Invalid token type!"):
provider._paypal_get_token()
def test_no_token(self):
@@ -205,7 +207,9 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
_provider_class + "._paypal_retrieve",
return_value=mocked_response,
):
with self.assertRaises(Exception):
with self.assertRaisesRegex(
UserError, "Failed to acquire token using Client ID and Secret!"
):
provider._paypal_get_token()
def test_no_data_on_monday(self):
@@ -434,7 +438,11 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase):
_provider_class + "._paypal_retrieve",
return_value=mocked_response,
), self.mock_token():
with self.assertRaises(Exception):
with self.assertRaisesRegex(
UserError,
"PayPal allows retrieving transactions only up to 3 years in "
"the past. Please import older transactions manually.",
):
provider._obtain_statement_data(
self.now - relativedelta(years=5),
self.now,