From 2959622de43007f1e29f2036573a7b2ceeffc364 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Fri, 2 Feb 2024 10:20:26 +0100 Subject: [PATCH] [IMP] account_statement_import_online_ponto: adapt to debug mechanism --- .../online_bank_statement_provider_ponto.py | 12 +++++++++-- ...t_account_statement_import_online_ponto.py | 21 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/account_statement_import_online_ponto/models/online_bank_statement_provider_ponto.py b/account_statement_import_online_ponto/models/online_bank_statement_provider_ponto.py index ec5adc6f..c3a21f27 100644 --- a/account_statement_import_online_ponto/models/online_bank_statement_provider_ponto.py +++ b/account_statement_import_online_ponto/models/online_bank_statement_provider_ponto.py @@ -49,11 +49,18 @@ class OnlineBankStatementProvider(models.Model): """ # pylint: disable=missing-return ponto_providers = self.filtered(lambda provider: provider.service == "ponto") - super(OnlineBankStatementProvider, self - ponto_providers)._pull( + debug = self.env.context.get("account_statement_online_import_debug") + debug_data = [] + data = super(OnlineBankStatementProvider, self - ponto_providers)._pull( date_since, date_until ) + if debug: + debug_data += data for provider in ponto_providers: - provider._ponto_pull(date_since, date_until) + data = provider._ponto_pull(date_since, date_until) + if debug: + debug_data += data + return debug_data def _ponto_pull(self, date_since, date_until): """Translate information from Ponto to Odoo bank statement lines.""" @@ -84,6 +91,7 @@ class OnlineBankStatementProvider(models.Model): if is_scheduled: self.ponto_last_identifier = lines[0].get("id") self._ponto_store_lines(lines) + return lines def _ponto_retrieve_data(self, date_since, date_until): """Fill buffer with data from Ponto. diff --git a/account_statement_import_online_ponto/tests/test_account_statement_import_online_ponto.py b/account_statement_import_online_ponto/tests/test_account_statement_import_online_ponto.py index 34157676..91ad8314 100644 --- a/account_statement_import_online_ponto/tests/test_account_statement_import_online_ponto.py +++ b/account_statement_import_online_ponto/tests/test_account_statement_import_online_ponto.py @@ -407,3 +407,24 @@ class TestAccountStatementImportOnlinePonto(common.TransactionCase): "account_number": "XX00 0000 0000 0000", } ], {} + + def test_wizard_action_debug(self): + """Debug data is returned properly.""" + statement_date = datetime(2019, 11, 1) + data = self._get_statement_line_data(statement_date) + self.provider.statement_creation_mode = "daily" + self.provider._create_or_update_statement( + data, statement_date, datetime(2019, 11, 2) + ) + with self.mock_login(), self.mock_set_access_account(), self.mock_get_transactions(): # noqa: B950 + vals = { + "date_since": datetime(2019, 11, 4), + "date_until": datetime(2019, 11, 5), + } + wizard = self.AccountStatementPull.with_context( + active_model=self.provider._name, + active_id=self.provider.id, + ).create(vals) + action = wizard.action_debug() + debug_wizard = self.env[action["res_model"]].browse(action["res_id"]) + self.assertIn("Laboriosam repelo", debug_wizard.data)