diff --git a/account_statement_import_online_paypal/__manifest__.py b/account_statement_import_online_paypal/__manifest__.py index d4b785bd..3e0bce30 100644 --- a/account_statement_import_online_paypal/__manifest__.py +++ b/account_statement_import_online_paypal/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Online Bank Statements: PayPal.com", - "version": "15.0.1.1.1", + "version": "16.0.1.0.0", "author": "CorporateHub, Odoo Community Association (OCA)", "maintainers": ["alexey-pelykh"], "website": "https://github.com/OCA/bank-statement-import", diff --git a/account_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py b/account_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py index b48b3991..4eb5a2f2 100644 --- a/account_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py +++ b/account_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py @@ -206,11 +206,8 @@ class OnlineBankStatementProviderPayPal(models.Model): token, currency, date_since, date_until ) if not transactions: - if self.allow_empty_statements: - balance = self._paypal_get_balance(token, currency, date_since) - return [], {"balance_start": balance, "balance_end_real": balance} - else: - return None + balance = self._paypal_get_balance(token, currency, date_since) + return [], {"balance_start": balance, "balance_end_real": balance} # Normalize transactions, sort by date, and get lines transactions = list( @@ -416,7 +413,6 @@ class OnlineBankStatementProviderPayPal(models.Model): interval_start.weekday() == 0 and (datetime.utcnow() - interval_start).total_seconds() < 28800, ) - data = self.with_context( invalid_data_workaround=invalid_data_workaround, )._paypal_retrieve(url, token) diff --git a/account_statement_import_online_paypal/tests/test_account_statement_import_online_paypal.py b/account_statement_import_online_paypal/tests/test_account_statement_import_online_paypal.py index fb02795b..b029e49d 100644 --- a/account_statement_import_online_paypal/tests/test_account_statement_import_online_paypal.py +++ b/account_statement_import_online_paypal/tests/test_account_statement_import_online_paypal.py @@ -275,7 +275,7 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase): self.now, ) - self.assertEqual(data, None) + self.assertEqual(data, ([], {"balance_start": 0.75, "balance_end_real": 0.75})) def test_error_handling_1(self): journal = self.AccountJournal.create( @@ -331,81 +331,6 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase): with self.assertRaises(UserError): provider._paypal_retrieve("https://url", "") - def test_dont_create_empty_paypal_statements(self): - """Test the default behavior of not creating empty PayPal - statements ('Allow empty statements' field is unchecked). - """ - journal = self.AccountJournal.create( - { - "name": "Bank", - "type": "bank", - "code": "BANK", - "currency_id": self.currency_eur.id, - "bank_statements_source": "online", - "online_bank_statement_provider": "paypal", - } - ) - - provider = journal.online_bank_statement_provider_id - mocked_response_1 = json.loads( - """{ - "transaction_details": [], - "account_number": "1234567890", - "start_date": "%s", - "end_date": "%s", - "last_refreshed_datetime": "%s", - "page": 1, - "total_items": 0, - "total_pages": 0 -}""" - % ( - self.now_isoformat, - self.now_isoformat, - self.now_isoformat, - ), - parse_float=Decimal, - ) - mocked_response_2 = json.loads( - """{ - "balances": [ - { - "currency": "EUR", - "primary": true, - "total_balance": { - "currency_code": "EUR", - "value": "0.75" - }, - "available_balance": { - "currency_code": "EUR", - "value": "0.75" - }, - "withheld_balance": { - "currency_code": "EUR", - "value": "0.00" - } - } - ], - "account_id": "1234567890", - "as_of_time": "%s", - "last_refresh_time": "%s" -}""" - % ( - self.now_isoformat, - self.now_isoformat, - ), - parse_float=Decimal, - ) - with mock.patch( - _provider_class + "._paypal_retrieve", - side_effect=[mocked_response_1, mocked_response_2], - ), self.mock_token(): - data = provider._obtain_statement_data( - self.now - relativedelta(hours=1), - self.now, - ) - - self.assertEqual(data, None) - def test_create_empty_paypal_statements(self): """Test creating empty PayPal statements ('Allow empty statements' field is checked). @@ -422,7 +347,6 @@ class TestAccountBankAccountStatementImportOnlinePayPal(common.TransactionCase): ) provider = journal.online_bank_statement_provider_id - provider.allow_empty_statements = True mocked_response_1 = json.loads( """{ "transaction_details": [],