[IMP] account_statement_import_online_ponto: adapt to debug mechanism

This commit is contained in:
Stefan Rijnhart
2024-02-02 10:20:26 +01:00
committed by Christian
parent bb4c9e4b96
commit 2959622de4
2 changed files with 31 additions and 2 deletions

View File

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

View File

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