From 393cca3a62bc1db818849e29b54f4df29fb369db Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Sun, 11 Oct 2026 15:48:31 +0200 Subject: [PATCH] [IMP] Add upload state tracking on EBICS payment files account_ebics: - Add pain_state and ebics_order_number to ebics.file - Set these fields after a successful upload - Add neutralized property to api.Environment account_ebics_batch_payment: - Add EBICS notebook page with upload info to batch payment form - Post chatter message with OrderID after upload account_ebics_payment_order: - Fix broken postprocess: replace deprecated active_model/active_id context keys with model/id --- account_ebics/__init__.py | 22 ++++++++++++++ account_ebics/__manifest__.py | 2 +- account_ebics/models/ebics_file.py | 6 ++++ account_ebics/views/ebics_file_views.xml | 4 +++ account_ebics/wizards/ebics_xfer.py | 37 +++++++++++++++++------- 5 files changed, 60 insertions(+), 11 deletions(-) diff --git a/account_ebics/__init__.py b/account_ebics/__init__.py index 168985a..ecdeb04 100644 --- a/account_ebics/__init__.py +++ b/account_ebics/__init__.py @@ -1,5 +1,8 @@ +import functools import logging +from odoo import api + _logger = logging.getLogger(__name__) try: @@ -7,3 +10,22 @@ try: from . import wizards except Exception: _logger.warning("Import Error, check if fintech lib has been installed") + + +@functools.cached_property +def neutralized(self): + return bool( + self["ir.config_parameter"].sudo().get_param("database.is_neutralized") + or self["ir.ui.view"] + .sudo() + .search_count( + [ + ("key", "in", ("web.neutralize_banner", "website.neutralize_ribbon")), + ("active", "=", True), + ] + ) + ) + + +api.Environment.neutralized = neutralized +neutralized.__set_name__(api.Environment, "neutralized") diff --git a/account_ebics/__manifest__.py b/account_ebics/__manifest__.py index 749a710..970f31c 100644 --- a/account_ebics/__manifest__.py +++ b/account_ebics/__manifest__.py @@ -5,7 +5,7 @@ "name": "EBICS Banking Protocol", "summary": "Download bank statements and upload payment " "files directly from Odoo, using the European EBICS standard", - "version": "19.0.1.2.0", + "version": "19.0.1.3.0", "license": "LGPL-3", "author": "Noviat", "website": "https://www.noviat.com/", diff --git a/account_ebics/models/ebics_file.py b/account_ebics/models/ebics_file.py index ca68b09..6c2cca5 100644 --- a/account_ebics/models/ebics_file.py +++ b/account_ebics/models/ebics_file.py @@ -70,6 +70,12 @@ class EbicsFile(models.Model): readonly=True, ) note = fields.Text(string="Notes") + ebics_order_number = fields.Char(string="EBICS OrderID", readonly=True) + pain_state = fields.Selection( + [("draft", "Draft"), ("uploaded", "Uploaded"), ("error", "Error")], + default="draft", + readonly=True, + ) note_process = fields.Text( string="Process Notes", readonly=True, diff --git a/account_ebics/views/ebics_file_views.xml b/account_ebics/views/ebics_file_views.xml index 1368a56..edf2e22 100644 --- a/account_ebics/views/ebics_file_views.xml +++ b/account_ebics/views/ebics_file_views.xml @@ -135,6 +135,10 @@ string="Upload Date" invisible="context.get('ebics_mode') == 'down'" /> + diff --git a/account_ebics/wizards/ebics_xfer.py b/account_ebics/wizards/ebics_xfer.py index a284409..be700b7 100644 --- a/account_ebics/wizards/ebics_xfer.py +++ b/account_ebics/wizards/ebics_xfer.py @@ -406,11 +406,9 @@ class EbicsXfer(models.TransientModel): self.note += self.env._( "EBICS File has been uploaded (OrderID %s).", OrderID ) - ef_note = self.env._("EBICS OrderID: %s", OrderID) + ef_note = "" if self.env.context.get("origin"): - ef_note += "\n" + self.env._( - "Origin: %s", self.env.context["origin"] - ) + ef_note = self.env._("Origin: %s", self.env.context["origin"]) suffix = self.format_id.suffix fn = self.upload_fname if suffix and not fn.endswith(suffix): @@ -430,6 +428,9 @@ class EbicsXfer(models.TransientModel): } self._update_ef_vals(ef_vals) ebics_file = self.env["ebics.file"].create(ef_vals) + ebics_file.write( + {"ebics_order_number": OrderID, "pain_state": "uploaded"} + ) except EbicsFunctionalError: e = exc_info() @@ -458,16 +459,32 @@ class EbicsXfer(models.TransientModel): OrderID = self.ebics_config_id._get_order_number() self.ebics_config_id.sudo()._update_order_number(OrderID) - ebics_file and self._payment_order_postprocess(ebics_file) + ebics_file and self._payment_upload_postprocess(ebics_file) return ebics_file - def _payment_order_postprocess(self, ebics_file): - active_model = self.env.context.get("model") + def _payment_upload_postprocess(self, ebics_file): + ctx = self.env.context + active_model = ctx.get("model") + active_id = ctx.get("id") + payment_doc = None if active_model == "account.payment.order": - order = self.env["account.payment.order"].browse( - self.env.context["active_id"] + payment_doc = self.env["account.payment.order"].browse(active_id) + payment_doc.generated2uploaded() + elif active_model == "account.batch.payment": + payment_doc = self.env["account.batch.payment"].browse(active_id) + if payment_doc: + payment_doc.ebics_file_id = ebics_file + self._payment_upload_chatter_message(payment_doc, ebics_file) + + def _payment_upload_chatter_message(self, payment_doc, ebics_file): + payment_doc.message_post( + body=self.env._( + "'%(filename)s' has been uploaded via EBICS" + " (OrderID: %(order_number)s).", + filename=ebics_file.name, + order_number=ebics_file.ebics_order_number, ) - order.generated2uploaded() + ) def _setup_client(self): self.ebics_config_id._check_ebics_keys()