diff --git a/account_bank_statement_import_online_adyen/models/online_bank_statement_provider.py b/account_bank_statement_import_online_adyen/models/online_bank_statement_provider.py index f938d7f1..5d982f16 100644 --- a/account_bank_statement_import_online_adyen/models/online_bank_statement_provider.py +++ b/account_bank_statement_import_online_adyen/models/online_bank_statement_provider.py @@ -84,10 +84,18 @@ class OnlineBankStatementProvider(models.Model): [self.api_base, self.journal_id.adyen_merchant_account, filename] ) response = requests.get(URL, auth=(self.username, self.password)) - if response.status_code == 200: - return response.content, filename - else: + if response.status_code != 200: raise UserError(_("%s \n\n %s") % (response.status_code, response.text)) + # Check base64 decoding and padding of response.content. + # Remember: response.text is unicode, response.content is in bytes. + byte_count = len(response.content) + _logger.debug( + _("Retrieved %d bytes, starting with %s"), byte_count, response.text[:32] + ) + # Make sure base64 encoded content contains multiple of 4 bytes. + byte_padding = b"=" * (byte_count % 4) + data_file = response.content + byte_padding + return data_file, filename def _schedule_next_run(self): """Set next run date and autoincrement batch number.""" diff --git a/setup/account_bank_statement_import_online_adyen/odoo/addons/account_bank_statement_import_online_adyen b/setup/account_bank_statement_import_online_adyen/odoo/addons/account_bank_statement_import_online_adyen new file mode 120000 index 00000000..fa446601 --- /dev/null +++ b/setup/account_bank_statement_import_online_adyen/odoo/addons/account_bank_statement_import_online_adyen @@ -0,0 +1 @@ +../../../../account_bank_statement_import_online_adyen \ No newline at end of file diff --git a/setup/account_bank_statement_import_online_adyen/setup.py b/setup/account_bank_statement_import_online_adyen/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/account_bank_statement_import_online_adyen/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)