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()
diff --git a/account_ebics_batch_payment/__manifest__.py b/account_ebics_batch_payment/__manifest__.py
index f66ac1c..2888320 100644
--- a/account_ebics_batch_payment/__manifest__.py
+++ b/account_ebics_batch_payment/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "EBICS - Batch Payments (Odoo Enterprise)",
"summary": "Send an Odoo Enterprise batch payment to the bank over EBICS",
- "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_batch_payment/models/account_batch_payment.py b/account_ebics_batch_payment/models/account_batch_payment.py
index f6eecf9..1c99c10 100644
--- a/account_ebics_batch_payment/models/account_batch_payment.py
+++ b/account_ebics_batch_payment/models/account_batch_payment.py
@@ -8,19 +8,47 @@ from odoo.exceptions import UserError
class AccountBatchPayment(models.Model):
_inherit = "account.batch.payment"
+ ebics_config_id = fields.Many2one(
+ comodel_name="ebics.config",
+ related="journal_id.ebics_config_id",
+ )
+ ebics_file_id = fields.Many2one(
+ comodel_name="ebics.file",
+ string="EBICS Upload File",
+ readonly=True,
+ )
+ ebics_pain_state = fields.Selection(
+ related="ebics_file_id.pain_state",
+ string="EBICS Upload Status",
+ )
+ ebics_order_number = fields.Char(
+ related="ebics_file_id.ebics_order_number",
+ string="EBICS OrderID",
+ )
hide_ebics_upload = fields.Boolean(
compute="_compute_hide_ebics_upload", default=True
)
- @api.depends("journal_id.ebics_config_id", "file_generation_enabled", "state")
+ @api.depends(
+ "journal_id.ebics_config_id",
+ "file_generation_enabled",
+ "state",
+ "ebics_file_id.pain_state",
+ )
def _compute_hide_ebics_upload(self):
for rec in self:
rec.hide_ebics_upload = (
- not rec.journal_id.ebics_config_id
+ self.env.neutralized
+ or not rec.journal_id.ebics_config_id
or not rec.file_generation_enabled
or rec.state != "sent"
+ or rec.ebics_pain_state == "uploaded"
)
+ def export_batch_payment(self):
+ self.filtered("ebics_file_id").write({"ebics_file_id": False})
+ return super().export_batch_payment()
+
def ebics_upload(self):
self.ensure_one()
ctx = self.env.context.copy()
@@ -38,6 +66,8 @@ class AccountBatchPayment(models.Model):
"default_upload_data": self.export_file,
"default_upload_fname": self.export_filename,
"origin": origin,
+ "model": self._name,
+ "id": self.id,
}
)
diff --git a/account_ebics_batch_payment/views/account_batch_payment_views.xml b/account_ebics_batch_payment/views/account_batch_payment_views.xml
index 3bdf1fd..b247106 100644
--- a/account_ebics_batch_payment/views/account_batch_payment_views.xml
+++ b/account_ebics_batch_payment/views/account_batch_payment_views.xml
@@ -14,6 +14,19 @@
class="oe_highlight"
/>
+
+
+
+
+
+
+
+
+
diff --git a/account_ebics_payment_order/__manifest__.py b/account_ebics_payment_order/__manifest__.py
index a2184e8..64f2690 100644
--- a/account_ebics_payment_order/__manifest__.py
+++ b/account_ebics_payment_order/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "EBICS - Payment Orders (OCA)",
"summary": "Send an OCA payment order to the bank over EBICS",
- "version": "19.0.1.0.0",
+ "version": "19.0.1.0.1",
"license": "LGPL-3",
"author": "Noviat",
"website": "https://www.noviat.com/",
diff --git a/account_ebics_payment_order/models/account_payment_order.py b/account_ebics_payment_order/models/account_payment_order.py
index c28aa65..5c70d6d 100644
--- a/account_ebics_payment_order/models/account_payment_order.py
+++ b/account_ebics_payment_order/models/account_payment_order.py
@@ -29,7 +29,8 @@ class AccountPaymentOrder(models.Model):
)
ctx.update(
{
- "active_model": self._name,
+ "model": self._name,
+ "id": self.id,
"default_format_id": ebics_format_id.id,
}
)