From 022491914dd8c451cffc1715c3f53b38881a6ba9 Mon Sep 17 00:00:00 2001 From: davidwul Date: Thu, 7 Mar 2024 13:22:51 +0100 Subject: [PATCH] fix backend name and add auto post feature (#19) * backend type need to be the same name as defined in xml * Add the auto post ability and the description en the readme. --- account_statement_import_sftp/README.rst | 2 ++ .../components/account_statement_import_process.py | 7 ++++++- account_statement_import_sftp/readme/USAGE.rst | 2 ++ .../static/description/index.html | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/account_statement_import_sftp/README.rst b/account_statement_import_sftp/README.rst index 1897e318e..d993649de 100644 --- a/account_statement_import_sftp/README.rst +++ b/account_statement_import_sftp/README.rst @@ -46,6 +46,8 @@ Usage To use this module you should configure an exchange type and a backend SFTP. Then when the scheduled action of EDI will run you will get your statement imported automatically. +To post the statement at import create a config parameter import_statement_edi_auto_post with True as value + Bug Tracker =========== diff --git a/account_statement_import_sftp/components/account_statement_import_process.py b/account_statement_import_sftp/components/account_statement_import_process.py index 5db7f2ce4..46b756bd5 100644 --- a/account_statement_import_sftp/components/account_statement_import_process.py +++ b/account_statement_import_sftp/components/account_statement_import_process.py @@ -2,6 +2,7 @@ # @author: Simon Gonzalez # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import _ +from odoo.tools import str2bool from odoo.addons.component.core import Component @@ -9,10 +10,12 @@ class EdiBankStatementImportProcess(Component): _name = "edi.input.process.bank.statement.import" _usage = "input.process" - _backend_type = "bk_sftp" + _backend_type = "bk_sftp_imp" _inherit = "edi.component.input.mixin" def process(self): + ir_config = self.env["ir.config_parameter"].sudo() + auto_post = str2bool(ir_config.get_param("import_statement_edi_auto_post")) statement_import = self.env["account.statement.import"].create( [ { @@ -27,3 +30,5 @@ def process(self): statement = self.env["account.bank.statement"].browse(action.get("res_id")) if not (statement.state and statement.state in ["posted", "open"]): raise ValueError(_("The bank statement could not be validated.")) + if auto_post: + statement.button_post() diff --git a/account_statement_import_sftp/readme/USAGE.rst b/account_statement_import_sftp/readme/USAGE.rst index a2aba212b..83f51f47f 100644 --- a/account_statement_import_sftp/readme/USAGE.rst +++ b/account_statement_import_sftp/readme/USAGE.rst @@ -1,2 +1,4 @@ To use this module you should configure an exchange type and a backend SFTP. Then when the scheduled action of EDI will run you will get your statement imported automatically. + +To post the statement at import create a config parameter import_statement_edi_auto_post with True as value diff --git a/account_statement_import_sftp/static/description/index.html b/account_statement_import_sftp/static/description/index.html index e8d7f2a9b..8526d7a21 100644 --- a/account_statement_import_sftp/static/description/index.html +++ b/account_statement_import_sftp/static/description/index.html @@ -392,6 +392,7 @@

Configuration

Usage

To use this module you should configure an exchange type and a backend SFTP. Then when the scheduled action of EDI will run you will get your statement imported automatically.

+

To post the statement at import create a config parameter import_statement_edi_auto_post with True as value

Bug Tracker