mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[IMP] account_statement_import_online: Add debug wizard
It's useful to debug RAW data received from your online sources. With this improvement, you can do it easily from the manual pull wizard. It's only available for users in debug mode (or with technical features). TT47238
This commit is contained in:
@@ -7,7 +7,7 @@ Online Bank Statements
|
|||||||
!! This file is generated by oca-gen-addon-readme !!
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
!! changes will be overwritten. !!
|
!! changes will be overwritten. !!
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! source digest: sha256:2b6c268fc49f5581274d78a7e7c753ac5ef98d158df29ea26bef98867d266dff
|
!! source digest: sha256:f9d33e5edb980fbe8f48c2777b4d360b8688dc93160aacd970d55d604d269ded
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"data/account_statement_import_online.xml",
|
"data/account_statement_import_online.xml",
|
||||||
"security/ir.model.access.csv",
|
"security/ir.model.access.csv",
|
||||||
"security/online_bank_statement_provider.xml",
|
"security/online_bank_statement_provider.xml",
|
||||||
|
"wizards/online_bank_statement_pull_debug.xml",
|
||||||
"wizards/online_bank_statement_pull_wizard.xml",
|
"wizards/online_bank_statement_pull_wizard.xml",
|
||||||
"views/actions.xml",
|
"views/actions.xml",
|
||||||
"views/account_journal.xml",
|
"views/account_journal.xml",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# Copyright 2019-2020 Brainbean Apps (https://brainbeanapps.com)
|
# Copyright 2019-2020 Brainbean Apps (https://brainbeanapps.com)
|
||||||
# Copyright 2019-2020 Dataplug (https://dataplug.io)
|
# Copyright 2019-2020 Dataplug (https://dataplug.io)
|
||||||
|
# Copyright 2014 Tecnativa - Pedro M. Baeza
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@@ -146,6 +147,8 @@ class OnlineBankStatementProvider(models.Model):
|
|||||||
|
|
||||||
def _pull(self, date_since, date_until):
|
def _pull(self, date_since, date_until):
|
||||||
is_scheduled = self.env.context.get("scheduled")
|
is_scheduled = self.env.context.get("scheduled")
|
||||||
|
debug = self.env.context.get("account_statement_online_import_debug")
|
||||||
|
debug_data = []
|
||||||
for provider in self:
|
for provider in self:
|
||||||
statement_date_since = provider._get_statement_date_since(date_since)
|
statement_date_since = provider._get_statement_date_since(date_since)
|
||||||
while statement_date_since < date_until:
|
while statement_date_since < date_until:
|
||||||
@@ -182,12 +185,16 @@ class OnlineBankStatementProvider(models.Model):
|
|||||||
)
|
)
|
||||||
break
|
break
|
||||||
raise
|
raise
|
||||||
provider._create_or_update_statement(
|
if debug:
|
||||||
data, statement_date_since, statement_date_until
|
debug_data += data
|
||||||
)
|
else:
|
||||||
|
provider._create_or_update_statement(
|
||||||
|
data, statement_date_since, statement_date_until
|
||||||
|
)
|
||||||
statement_date_since = statement_date_until
|
statement_date_since = statement_date_until
|
||||||
if is_scheduled:
|
if is_scheduled:
|
||||||
provider._schedule_next_run()
|
provider._schedule_next_run()
|
||||||
|
return debug_data
|
||||||
|
|
||||||
def _create_or_update_statement(
|
def _create_or_update_statement(
|
||||||
self, data, statement_date_since, statement_date_until
|
self, data, statement_date_since, statement_date_until
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
access_online_bank_statement_provider_admin,online.bank.statement.provider:base.group_system,model_online_bank_statement_provider,base.group_system,1,1,1,1
|
access_online_bank_statement_provider_admin,online.bank.statement.provider:base.group_system,model_online_bank_statement_provider,base.group_system,1,1,1,1
|
||||||
access_online_bank_statement_provider_user,online.bank.statement.provider:account.group_account_user,model_online_bank_statement_provider,account.group_account_user,1,1,1,1
|
access_online_bank_statement_provider_user,online.bank.statement.provider:account.group_account_user,model_online_bank_statement_provider,account.group_account_user,1,1,1,1
|
||||||
|
access_online_bank_statement_pull_debug_user,online.bank.statement.pull.debug:account.group_account_user,model_online_bank_statement_pull_debug,account.group_account_user,1,1,1,1
|
||||||
access_online_bank_statement_pull_wizard_user,online.bank.statement.pull.wizard:account.group_account_user,model_online_bank_statement_pull_wizard,account.group_account_user,1,1,1,1
|
access_online_bank_statement_pull_wizard_user,online.bank.statement.pull.wizard:account.group_account_user,model_online_bank_statement_pull_wizard,account.group_account_user,1,1,1,1
|
||||||
|
|||||||
|
@@ -367,7 +367,7 @@ ul.auto-toc {
|
|||||||
!! This file is generated by oca-gen-addon-readme !!
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
!! changes will be overwritten. !!
|
!! changes will be overwritten. !!
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! source digest: sha256:2b6c268fc49f5581274d78a7e7c753ac5ef98d158df29ea26bef98867d266dff
|
!! source digest: sha256:f9d33e5edb980fbe8f48c2777b4d360b8688dc93160aacd970d55d604d269ded
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/bank-statement-import/tree/15.0/account_statement_import_online"><img alt="OCA/bank-statement-import" src="https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/bank-statement-import-15-0/bank-statement-import-15-0-account_statement_import_online"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/bank-statement-import&target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/bank-statement-import/tree/15.0/account_statement_import_online"><img alt="OCA/bank-statement-import" src="https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/bank-statement-import-15-0/bank-statement-import-15-0-account_statement_import_online"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/bank-statement-import&target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||||
<p>This module provides base for building online bank statements providers.</p>
|
<p>This module provides base for building online bank statements providers.</p>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from . import online_bank_statement_pull_debug
|
||||||
from . import online_bank_statement_pull_wizard
|
from . import online_bank_statement_pull_wizard
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# Copyright 2024 Tecnativa - Pedro M. Baeza
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class OnlineBankStatementPullWizard(models.TransientModel):
|
||||||
|
_name = "online.bank.statement.pull.debug"
|
||||||
|
_description = "Online Bank Statement Pull Debug Wizard"
|
||||||
|
|
||||||
|
data = fields.Text(string="RAW data", required=True, readonly=True)
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!--
|
||||||
|
Copyright 2024 Tecnativa - Pedro M. Baeza
|
||||||
|
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
-->
|
||||||
|
<odoo>
|
||||||
|
<record id="online_bank_statement_pull_debug_form" model="ir.ui.view">
|
||||||
|
<field name="model">online.bank.statement.pull.debug</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form>
|
||||||
|
<field name="data" />
|
||||||
|
<footer>
|
||||||
|
<button string="Close" special="cancel" />
|
||||||
|
</footer>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<record id="online_bank_statement_pull_debug_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Online bank statements - Debug</field>
|
||||||
|
<field name="res_model">online.bank.statement.pull.debug</field>
|
||||||
|
<field name="view_mode">form</field>
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
# Copyright 2019-2020 Dataplug (https://dataplug.io)
|
# Copyright 2019-2020 Dataplug (https://dataplug.io)
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
import pprint
|
||||||
|
|
||||||
from odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
@@ -60,3 +62,18 @@ class OnlineBankStatementPullWizard(models.TransientModel):
|
|||||||
("journal_id", "in", [o.journal_id.id for o in self.provider_ids])
|
("journal_id", "in", [o.journal_id.id for o in self.provider_ids])
|
||||||
]
|
]
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
def action_debug(self):
|
||||||
|
"""Pull statements in debug and show result."""
|
||||||
|
self.ensure_one()
|
||||||
|
data = self.with_context(
|
||||||
|
active_test=False, account_statement_online_import_debug=True
|
||||||
|
).provider_ids._pull(self.date_since, self.date_until)
|
||||||
|
wizard = self.env["online.bank.statement.pull.debug"].create(
|
||||||
|
{"data": pprint.pformat(data)}
|
||||||
|
)
|
||||||
|
action = self.env["ir.actions.act_window"]._for_xml_id(
|
||||||
|
"account_statement_import_online.online_bank_statement_pull_debug_action"
|
||||||
|
)
|
||||||
|
action["res_id"] = wizard.id
|
||||||
|
return action
|
||||||
|
|||||||
@@ -28,6 +28,12 @@
|
|||||||
default_focus="1"
|
default_focus="1"
|
||||||
class="btn-primary"
|
class="btn-primary"
|
||||||
/>
|
/>
|
||||||
|
<button
|
||||||
|
name="action_debug"
|
||||||
|
string="Debug"
|
||||||
|
type="object"
|
||||||
|
groups="base.group_no_one"
|
||||||
|
/>
|
||||||
<button string="Cancel" special="cancel" />
|
<button string="Cancel" special="cancel" />
|
||||||
</footer>
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user