Merge PR #660 into 15.0

Signed-off-by pedrobaeza
This commit is contained in:
OCA-git-bot
2024-02-02 17:57:38 +00:00
10 changed files with 75 additions and 6 deletions

View File

@@ -7,7 +7,7 @@ Online Bank Statements
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2b6c268fc49f5581274d78a7e7c753ac5ef98d158df29ea26bef98867d266dff
!! source digest: sha256:f9d33e5edb980fbe8f48c2777b4d360b8688dc93160aacd970d55d604d269ded
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png

View File

@@ -19,6 +19,7 @@
"data/account_statement_import_online.xml",
"security/ir.model.access.csv",
"security/online_bank_statement_provider.xml",
"wizards/online_bank_statement_pull_debug.xml",
"wizards/online_bank_statement_pull_wizard.xml",
"views/actions.xml",
"views/account_journal.xml",

View File

@@ -1,5 +1,6 @@
# Copyright 2019-2020 Brainbean Apps (https://brainbeanapps.com)
# 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).
import logging
@@ -146,6 +147,8 @@ class OnlineBankStatementProvider(models.Model):
def _pull(self, date_since, date_until):
is_scheduled = self.env.context.get("scheduled")
debug = self.env.context.get("account_statement_online_import_debug")
debug_data = []
for provider in self:
statement_date_since = provider._get_statement_date_since(date_since)
while statement_date_since < date_until:
@@ -182,12 +185,16 @@ class OnlineBankStatementProvider(models.Model):
)
break
raise
provider._create_or_update_statement(
data, statement_date_since, statement_date_until
)
if debug:
debug_data += data
else:
provider._create_or_update_statement(
data, statement_date_since, statement_date_until
)
statement_date_since = statement_date_until
if is_scheduled:
provider._schedule_next_run()
return debug_data
def _create_or_update_statement(
self, data, statement_date_since, statement_date_until

View File

@@ -1,4 +1,5 @@
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_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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 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
3 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
4 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
5 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

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! 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&amp;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>

View File

@@ -1,3 +1,4 @@
# 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

View File

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

View File

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

View File

@@ -2,6 +2,8 @@
# Copyright 2019-2020 Dataplug (https://dataplug.io)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import pprint
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])
]
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

View File

@@ -23,11 +23,18 @@
<footer>
<button
name="action_pull"
string="Pull"
string="Import Transactions"
type="object"
default_focus="1"
class="btn-primary"
/>
<button
name="action_debug"
string="Show Transaction Data"
help="Fetch and display transaction data (for debug purposes)"
type="object"
groups="base.group_no_one"
/>
<button string="Cancel" special="cancel" />
</footer>
</form>