[MIG] account_ebics: Migration to 18.0

This commit is contained in:
Luc De Meyer 2024-12-23 18:37:55 +01:00
parent 25c4606a05
commit 56ea15e447
13 changed files with 142 additions and 140 deletions

View File

@ -3,7 +3,7 @@
{
"name": "EBICS banking protocol",
"version": "17.0.1.1.2",
"version": "18.0.1.0.0",
"license": "LGPL-3",
"author": "Noviat",
"website": "https://www.noviat.com",

View File

@ -5,7 +5,7 @@ import logging
import os
import re
from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
@ -132,7 +132,7 @@ class EbicsConfig(models.Model):
def _check_ebics_key_bitlength(self):
for cfg in self:
if cfg.ebics_version == "H005" and cfg.ebics_key_bitlength < 2048:
raise UserError(_("EBICS key bitlength must be >= 2048."))
raise UserError(self.env._("EBICS key bitlength must be >= 2048."))
@api.constrains("order_number")
def _check_order_number(self):
@ -148,7 +148,7 @@ class EbicsConfig(models.Model):
ok = False
if not ok:
raise UserError(
_( # pylint: disable=W8120
self.env._( # pylint: disable=W8120
"Order Number should comply with the following pattern:"
"\n[A-Z]{1}[A-Z0-9]{3}"
)
@ -178,7 +178,9 @@ class EbicsConfig(models.Model):
def unlink(self):
for ebics_config in self:
if ebics_config.state == "active":
raise UserError(_("You cannot remove active EBICS configurations."))
raise UserError(
self.env._("You cannot remove active EBICS configurations.")
)
return super().unlink()
def set_to_draft(self):
@ -211,7 +213,7 @@ class EbicsConfig(models.Model):
dirname = self.ebics_keys or ""
if not os.path.exists(dirname):
raise UserError(
_(
self.env._(
"EBICS Keys Root Directory %s is not available."
"\nPlease contact your system administrator."
)

View File

@ -9,7 +9,7 @@ from traceback import format_exception
from lxml import etree
from odoo import _, fields, models
from odoo import fields, models
from odoo.exceptions import UserError
from odoo.addons.base.models.res_bank import sanitize_account_number
@ -86,7 +86,9 @@ class EbicsFile(models.Model):
ff_methods = self._file_format_methods()
for ebics_file in self:
if ebics_file.state == "done":
raise UserError(_("You can only remove EBICS files in state 'Draft'."))
raise UserError(
self.env._("You can only remove EBICS files in state 'Draft'.")
)
# execute format specific actions
ff = ebics_file.format_id.download_process_method
if ff in ff_methods:
@ -167,7 +169,7 @@ class EbicsFile(models.Model):
if not mod:
if raise_if_not_found:
raise UserError(
_(
self.env._(
"The module to process the '%(ebics_format)s' format is not "
"installed on your system. "
"\nPlease install module '%(module)s'",
@ -184,7 +186,7 @@ class EbicsFile(models.Model):
)
journal = self.env["account.journal"]
if not currency:
message = _("Currency %(cc)s not found.", cc=currency_code)
message = self.env._("Currency %(cc)s not found.", cc=currency_code)
res["notifications"].append({"type": "error", "message": message})
return (currency, journal)
@ -199,7 +201,7 @@ class EbicsFile(models.Model):
]
)
if not journals:
message = _(
message = self.env._(
"No financial journal found for Account Number %(nbr)s, "
"Currency %(cc)s",
nbr=acc_number,
@ -217,7 +219,7 @@ class EbicsFile(models.Model):
break
if not journal:
message = _(
message = self.env._(
"No financial journal found for Account Number %(nbr)s, "
"Currency %(cc)s",
nbr=acc_number,
@ -244,7 +246,7 @@ class EbicsFile(models.Model):
notifications.append(
{
"type": "warning",
"message": _("This file doesn't contain any transaction."),
"message": self.env._("This file doesn't contain any transaction."),
}
)
st_cnt = len(statements)
@ -265,28 +267,30 @@ class EbicsFile(models.Model):
warning_cnt += 1
warnings.append(notif + "\n")
self.note_process += _("Process file %(fn)s results:", fn=self.name)
self.note_process += self.env._("Process file %(fn)s results:", fn=self.name)
if error_cnt:
self.note_process += "\n\n" + _("Errors") + ":\n"
self.note_process += "\n\n" + self.env._("Errors") + ":\n"
self.note_process += "\n".join(errors)
self.note_process += "\n\n"
self.note_process += _("Number of errors: %(nr)s", nr=error_cnt)
self.note_process += self.env._("Number of errors: %(nr)s", nr=error_cnt)
if warning_cnt:
self.note_process += "\n\n" + _("Warnings") + ":\n"
self.note_process += "\n\n" + self.env._("Warnings") + ":\n"
self.note_process += "\n".join(warnings)
self.note_process += "\n\n"
self.note_process += _("Number of warnings: %(nr)s", nr=warning_cnt)
self.note_process += self.env._(
"Number of warnings: %(nr)s", nr=warning_cnt
)
self.note_process += "\n"
if st_cnt:
self.note_process += "\n\n"
self.note_process += _(
self.note_process += self.env._(
"%(st_cnt)s bank statement%(sp)s been imported: ",
st_cnt=st_cnt,
sp=st_cnt == 1 and _(" has") or _("s have"),
sp=st_cnt == 1 and self.env._(" has") or self.env._("s have"),
)
self.note_process += "\n"
for statement in statements:
self.note_process += "\n" + _(
self.note_process += "\n" + self.env._(
"Statement %(st)s dated %(date)s (Company: %(cpy)s)",
st=statement.name,
date=statement.date,
@ -300,7 +304,7 @@ class EbicsFile(models.Model):
module = __name__.split("addons.")[1].split(".")[0]
result_view = self.env.ref("%s.ebics_file_view_form_result" % module)
return {
"name": _("Import EBICS File"),
"name": self.env._("Import EBICS File"),
"res_id": self.id,
"view_type": "form",
"view_mode": "form",
@ -331,7 +335,7 @@ class EbicsFile(models.Model):
]
)
if dup:
message = _(
message = self.env._(
"Statement %(st_name)s dated %(date)s has already been imported.",
st_name=statement.name,
date=statement.date,
@ -369,7 +373,7 @@ class EbicsFile(models.Model):
file_data = base64.b64decode(self.data)
file_data.replace(b"\n", b"").replace(b"\r", b"")
if len(file_data) % 120:
message = _(
message = self.env._(
"Incorrect CFONB120 file:\n"
"the file is not divisible in 120 char lines"
)
@ -450,7 +454,7 @@ class EbicsFile(models.Model):
break
if not author:
raise UserError(
_(
self.env._(
"The module to process the '%(ebics_format)s' format is "
"not installed on your system. "
"\nPlease install one of the following modules: \n%(modules)s.",
@ -501,7 +505,7 @@ class EbicsFile(models.Model):
except UserError as e:
msg = "".join(e.args)
msg += "\n"
msg += _(
msg += self.env._(
"Statement for Account Number %(nr)s has not been processed.",
nr=st_data["acc_number"],
)
@ -555,7 +559,7 @@ class EbicsFile(models.Model):
file_data = base64.b64decode(self.data)
root = etree.fromstring(file_data, parser=etree.XMLParser(recover=True))
if root is None:
message = _("Invalid XML file.")
message = self.env._("Invalid XML file.")
res["notifications"].append({"type": "error", "message": message})
ns = {k or "ns": v for k, v in root.nsmap.items()}
camt_variant = ns["ns"].split("camt.")[1][:3]
@ -574,7 +578,7 @@ class EbicsFile(models.Model):
)[0]
)
if not acc_number:
message = _("No bank account number found.")
message = self.env._("No bank account number found.")
res["notifications"].append({"type": "error", "message": message})
continue
currency_code = stmt.xpath(
@ -626,7 +630,7 @@ class EbicsFile(models.Model):
def _process_undefined_format(self):
raise UserError(
_(
self.env._(
"The current version of the 'account_ebics' module "
"has no support to automatically process EBICS files "
"with format %s."

View File

@ -8,7 +8,7 @@ from sys import exc_info
from traceback import format_exception
from urllib.error import URLError
from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
@ -236,20 +236,26 @@ class EbicsUserID(models.Model):
def _check_ebics_key_x509(self):
for cfg in self:
if cfg.ebics_version == "H005" and not cfg.ebics_key_x509:
raise UserError(_("X.509 certificates must be used with EBICS 3.0."))
raise UserError(
self.env._("X.509 certificates must be used with EBICS 3.0.")
)
@api.constrains("ebics_passphrase")
def _check_ebics_passphrase(self):
for rec in self:
if rec.ebics_passphrase and len(rec.ebics_passphrase) < 8:
raise UserError(_("The Passphrase must be at least 8 characters long"))
raise UserError(
self.env._("The Passphrase must be at least 8 characters long")
)
@api.constrains("ebics_sig_passphrase")
def _check_ebics_sig_passphrase(self):
for rec in self:
if rec.ebics_sig_passphrase and len(rec.ebics_sig_passphrase) < 8:
raise UserError(
_("The Signature Passphrase must be at least 8 characters long")
self.env._(
"The Signature Passphrase must be at least 8 characters long"
)
)
@api.onchange("ebics_version")
@ -280,7 +286,7 @@ class EbicsUserID(models.Model):
# It will raise a ValueError on invalid passphrases
keyring["#USER"]
except ValueError as err: # noqa: F841
raise UserError(_("Passphrase mismatch.")) # noqa: B904
raise UserError(self.env._("Passphrase mismatch.")) # noqa: B904
else:
if self.state != "draft":
self.ebics_passphrase = False
@ -302,7 +308,7 @@ class EbicsUserID(models.Model):
self.ensure_one()
if self.ebics_config_id.state != "draft":
raise UserError(
_(
self.env._(
"Set the EBICS Configuation record to 'Draft' "
"before starting the Key Renewal process."
)
@ -317,14 +323,14 @@ class EbicsUserID(models.Model):
self.ensure_one()
if self.state != "draft":
raise UserError(
_("Set state to 'draft' before Bank Key (re)initialisation.")
self.env._("Set state to 'draft' before Bank Key (re)initialisation.")
)
if not self.ebics_passphrase:
raise UserError(_("Set a passphrase."))
raise UserError(self.env._("Set a passphrase."))
if self.swift_3skey and not self.swift_3skey_certificate:
raise UserError(_("3SKey certificate missing."))
raise UserError(self.env._("3SKey certificate missing."))
ebics_version = self.ebics_config_id.ebics_version
try:
@ -347,7 +353,7 @@ class EbicsUserID(models.Model):
)
except Exception as err:
exctype, value = exc_info()[:2]
error = _("EBICS Initialisation Error:")
error = self.env._("EBICS Initialisation Error:")
error += "\n" + str(exctype) + "\n" + str(value)
raise UserError(error) from err
@ -369,13 +375,13 @@ class EbicsUserID(models.Model):
)
except Exception as err:
exctype, value = exc_info()[:2]
error = _("EBICS Initialisation Error:")
error = self.env._("EBICS Initialisation Error:")
error += "\n" + str(exctype) + "\n" + str(value)
raise UserError(error) from err
if self.swift_3skey and not self.ebics_key_x509:
raise UserError(
_(
self.env._(
"The current version of this module "
"requires to X509 support when enabling 3SKey"
)
@ -398,7 +404,7 @@ class EbicsUserID(models.Model):
client = EbicsClient(bank, user, version=ebics_version)
except RuntimeError as err:
e = exc_info()
error = _("EBICS Initialization Error:")
error = self.env._("EBICS Initialization Error:")
error += "\n"
error += err.args[0]
raise UserError(error) from err
@ -407,13 +413,15 @@ class EbicsUserID(models.Model):
ebics_config_bank = self.ebics_config_id.journal_ids[0].bank_id
if not ebics_config_bank:
raise UserError(
_("No bank defined for the financial journal " "of the EBICS Config")
self.env._(
"No bank defined for the financial journal " "of the EBICS Config"
)
)
try:
supported_versions = client.HEV()
if supported_versions and ebics_version not in supported_versions:
err_msg = _("EBICS version mismatch.") + "\n"
err_msg += _("Versions supported by your bank:")
err_msg = self.env._("EBICS version mismatch.") + "\n"
err_msg += self.env._("Versions supported by your bank:")
for k in supported_versions:
err_msg += f"\n{k}: {supported_versions[k]} "
raise UserError(err_msg)
@ -432,7 +440,7 @@ class EbicsUserID(models.Model):
tb,
)
raise UserError(
_(
self.env._(
"urlopen error:\n url '%(url)s' - %(val)s",
url=self.ebics_config_id.ebics_url,
val=str(value),
@ -440,13 +448,13 @@ class EbicsUserID(models.Model):
) from err
except EbicsFunctionalError as err:
e = exc_info()
error = _("EBICS Functional Error:")
error = self.env._("EBICS Functional Error:")
error += "\n"
error += f"{e[1].message} (code: {e[1].code})"
raise UserError(error) from err
except EbicsTechnicalError as err:
e = exc_info()
error = _("EBICS Technical Error:")
error = self.env._("EBICS Technical Error:")
error += "\n"
error += f"{e[1].message} (code: {e[1].code})"
raise UserError(error) from err
@ -485,7 +493,7 @@ class EbicsUserID(models.Model):
"""
self.ensure_one()
if self.state != "init":
raise UserError(_("Set state to 'Initialisation'."))
raise UserError(self.env._("Set state to 'Initialisation'."))
vals = {"state": "get_bank_keys"}
self._update_passphrase_vals(vals)
return self.write(vals)
@ -499,7 +507,7 @@ class EbicsUserID(models.Model):
"""
self.ensure_one()
if self.state != "get_bank_keys":
raise UserError(_("Set state to 'Get Keys from Bank'."))
raise UserError(self.env._("Set state to 'Get Keys from Bank'."))
try:
keyring = EbicsKeyRing(
keys=self.ebics_keys_fn, passphrase=self.ebics_passphrase
@ -517,7 +525,7 @@ class EbicsUserID(models.Model):
client = EbicsClient(bank, user, version=self.ebics_config_id.ebics_version)
except Exception as err:
exctype, value = exc_info()[:2]
error = _("EBICS Initialisation Error:")
error = self.env._("EBICS Initialisation Error:")
error += "\n" + str(exctype) + "\n" + str(value)
raise UserError(error) from err
@ -525,13 +533,13 @@ class EbicsUserID(models.Model):
public_bank_keys = client.HPB()
except EbicsFunctionalError as err:
e = exc_info()
error = _("EBICS Functional Error:")
error = self.env._("EBICS Functional Error:")
error += "\n"
error += f"{e[1].message} (code: {e[1].code})"
raise UserError(error) from err
except Exception as err:
exctype, value = exc_info()[:2]
error = _("EBICS Initialisation Error:")
error = self.env._("EBICS Initialisation Error:")
error += "\n" + str(exctype) + "\n" + str(value)
raise UserError(error) from err
@ -557,7 +565,7 @@ class EbicsUserID(models.Model):
"""
self.ensure_one()
if self.state != "to_verify":
raise UserError(_("Set state to 'Verification'."))
raise UserError(self.env._("Set state to 'Verification'."))
keyring = EbicsKeyRing(
keys=self.ebics_keys_fn, passphrase=self.ebics_passphrase
@ -578,7 +586,7 @@ class EbicsUserID(models.Model):
module = __name__.split("addons.")[1].split(".")[0]
view = self.env.ref("%s.ebics_change_passphrase_view_form" % module)
return {
"name": _("EBICS keys change passphrase"),
"name": self.env._("EBICS keys change passphrase"),
"view_type": "form",
"view_mode": "form",
"res_model": "ebics.change.passphrase",

View File

@ -1,16 +1,16 @@
<?xml version="1.0" ?>
<odoo>
<record id="ebics_config_view_tree" model="ir.ui.view">
<field name="name">ebics.config.tree</field>
<record id="ebics_config_view_list" model="ir.ui.view">
<field name="name">ebics.config.list</field>
<field name="model">ebics.config</field>
<field name="arch" type="xml">
<tree decoration-muted="state == 'draft'">
<list decoration-muted="state == 'draft'">
<field name="name" />
<field name="ebics_host" />
<field name="state" />
<field name="active" />
</tree>
</list>
</field>
</record>
@ -39,7 +39,6 @@
/>
<field name="state" widget="statusbar" />
</header>
<field name="active" invisible="1" />
<widget
name="web_ribbon"
text="Archived"
@ -69,7 +68,6 @@
invisible="ebics_version != 'H003'"
readonly="state != 'draft'"
/>
<field name="company_ids" widget="many2many_tags" invisible="1" />
</group>
</group>
<notebook>
@ -87,7 +85,7 @@
<record id="ebics_config_action" model="ir.actions.act_window">
<field name="name">EBICS Configuration</field>
<field name="res_model">ebics.config</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="context">{'active_test': False}</field>
</record>

View File

@ -1,18 +1,18 @@
<?xml version="1.0" ?>
<odoo>
<record id="ebics_file_format_view_tree" model="ir.ui.view">
<field name="name">ebics.file.format.tree</field>
<record id="ebics_file_format_view_list" model="ir.ui.view">
<field name="name">ebics.file.format.list</field>
<field name="model">ebics.file.format</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="ebics_version" />
<field name="type" />
<field name="order_type" />
<field name="signature_class" />
<field name="name" />
<field name="description" />
</tree>
</list>
</field>
</record>
@ -68,7 +68,7 @@
<record id="ebics_file_format_action" model="ir.actions.act_window">
<field name="name">EBICS File Formats</field>
<field name="res_model">ebics.file.format</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
</record>
</odoo>

View File

@ -34,11 +34,11 @@
<!-- Download -->
<record id="ebics_file_view_tree_download" model="ir.ui.view">
<field name="name">ebics.file.tree</field>
<record id="ebics_file_view_list_download" model="ir.ui.view">
<field name="name">ebics.file.list</field>
<field name="model">ebics.file</field>
<field name="arch" type="xml">
<tree decoration-muted="state=='draft'" create="false">
<list decoration-muted="state=='draft'" create="false">
<field name="date" string="Download Date" />
<field name="name" />
<field name="date_from" />
@ -51,7 +51,7 @@
widget="many2many_tags"
groups="base.group_multi_company"
/>
</tree>
</list>
</field>
</record>
@ -140,16 +140,16 @@
<field name="name">EBICS Download Files</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">ebics.file</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="view_id" eval="False" />
<field name="domain">[('type','=','down')]</field>
<field name="search_view_id" ref="ebics_file_view_search" />
</record>
<record id="ebics_file_action_download_tree" model="ir.actions.act_window.view">
<record id="ebics_file_action_download_list" model="ir.actions.act_window.view">
<field eval="1" name="sequence" />
<field name="view_mode">tree</field>
<field name="view_id" ref="ebics_file_view_tree_download" />
<field name="view_mode">list</field>
<field name="view_id" ref="ebics_file_view_list_download" />
<field name="act_window_id" ref="ebics_file_action_download" />
</record>
@ -162,11 +162,11 @@
<!-- Upload -->
<record id="ebics_file_view_tree_upload" model="ir.ui.view">
<field name="name">ebics.file.tree</field>
<record id="ebics_file_view_list_upload" model="ir.ui.view">
<field name="name">ebics.file.list</field>
<field name="model">ebics.file</field>
<field name="arch" type="xml">
<tree decoration-muted="state=='draft'" create="false">
<list decoration-muted="state=='draft'" create="false">
<field name="date" string="Upload Date" />
<field name="name" />
<field name="user_id" />
@ -177,7 +177,7 @@
widget="many2many_tags"
groups="base.group_multi_company"
/>
</tree>
</list>
</field>
</record>
@ -230,16 +230,16 @@
<field name="name">EBICS Upload Files</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">ebics.file</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="view_id" eval="False" />
<field name="domain">[('type','=','up')]</field>
<field name="search_view_id" ref="ebics_file_view_search" />
</record>
<record id="ebics_file_action_upload_tree" model="ir.actions.act_window.view">
<record id="ebics_file_action_upload_list" model="ir.actions.act_window.view">
<field eval="1" name="sequence" />
<field name="view_mode">tree</field>
<field name="view_id" ref="ebics_file_view_tree_upload" />
<field name="view_mode">list</field>
<field name="view_id" ref="ebics_file_view_list_upload" />
<field name="act_window_id" ref="ebics_file_action_upload" />
</record>

View File

@ -1,16 +1,16 @@
<?xml version="1.0" ?>
<odoo>
<record id="ebics_userid_view_tree" model="ir.ui.view">
<field name="name">ebics.userid.tree</field>
<record id="ebics_userid_view_list" model="ir.ui.view">
<field name="name">ebics.userid.list</field>
<field name="model">ebics.userid</field>
<field name="arch" type="xml">
<tree decoration-muted="state != 'active_keys'">
<list decoration-muted="state != 'active_keys'">
<field name="name" />
<field name="signature_class" />
<field name="state" />
<field name="active" />
</tree>
</list>
</field>
</record>
@ -82,16 +82,6 @@
/>
<field name="state" widget="statusbar" />
</header>
<group name="invisible" invisible="1">
<field name="ebics_config_id" />
<field name="ebics_keys_found" />
<field name="ebics_keys_fn" />
<field name="ebics_version" />
<field name="ebics_passphrase_required" />
<field name="ebics_passphrase_invisible" />
<field name="ebics_passphrase_store_readonly" />
<field name="ebics_sig_passphrase_invisible" invisible="1" />
</group>
<group name="main" readonly="state != 'draft'">
<group name="main-left">
<field name="name" readonly="state != 'draft'" />

View File

@ -3,7 +3,7 @@
import pprint
from odoo import _, api, fields, models
from odoo import api, fields, models
class EbicsAdminOrder(models.TransientModel):
@ -30,7 +30,7 @@ class EbicsAdminOrder(models.TransientModel):
client = self._setup_client()
if not client:
self.note += (
_("EBICS client setup failed for connection '%s'")
self.env._("EBICS client setup failed for connection '%s'")
% self.ebics_config_id.name
)
else:
@ -40,7 +40,7 @@ class EbicsAdminOrder(models.TransientModel):
module = __name__.split("addons.")[1].split(".")[0]
result_view = self.env.ref("%s.ebics_admin_order_view_form_result" % module)
return {
"name": _("EBICS Administrative Order result"),
"name": self.env._("EBICS Administrative Order result"),
"res_id": self.id,
"view_type": "form",
"view_mode": "form",

View File

@ -3,7 +3,7 @@
import logging
from odoo import _, fields, models
from odoo import fields, models
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
@ -50,21 +50,23 @@ class EbicsChangePassphrase(models.TransientModel):
and self.old_pass
and self.old_pass != self.ebics_userid_id.ebics_passphrase
):
raise UserError(_("Incorrect old passphrase."))
raise UserError(self.env._("Incorrect old passphrase."))
if self.new_pass != self.new_pass_check:
raise UserError(_("New passphrase verification error."))
raise UserError(self.env._("New passphrase verification error."))
if self.new_pass and self.new_pass == self.ebics_userid_id.ebics_passphrase:
raise UserError(_("New passphrase equal to old passphrase."))
raise UserError(self.env._("New passphrase equal to old passphrase."))
if (
self.new_sig_pass
and self.old_sig_pass
and self.new_sig_pass == self.old_sig_pass
):
raise UserError(
_("New signature passphrase equal to old signature passphrase.")
self.env._(
"New signature passphrase equal to old signature passphrase."
)
)
if self.new_sig_pass != self.new_sig_pass_check:
raise UserError(_("New signature passphrase verification error."))
raise UserError(self.env._("New signature passphrase verification error."))
passphrase = (
self.ebics_userid_id.ebics_passphrase_store
and self.ebics_userid_id.ebics_passphrase
@ -105,7 +107,7 @@ class EbicsChangePassphrase(models.TransientModel):
"%s.ebics_change_passphrase_view_form_result" % module
)
return {
"name": _("EBICS Keys Change Passphrase"),
"name": self.env._("EBICS Keys Change Passphrase"),
"res_id": self.id,
"view_type": "form",
"view_mode": "form",

View File

@ -18,9 +18,6 @@
<field name="new_sig_pass" password="True" />
<field name="new_sig_pass_check" password="True" />
</group>
<group name="invisible" invisible="1">
<field name="ebics_sig_passphrase_invisible" />
</group>
</group>
<footer>
<button

View File

@ -6,7 +6,7 @@ import logging
from sys import exc_info
from traceback import format_exception
from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
@ -203,7 +203,7 @@ class EbicsXfer(models.TransientModel):
module = __name__.split("addons.")[1].split(".")[0]
result_view = self.env.ref("%s.ebics_xfer_view_form_result" % module)
return {
"name": _("EBICS file transfer result"),
"name": self.env._("EBICS file transfer result"),
"res_id": self.id,
"view_type": "form",
"view_mode": "form",
@ -223,7 +223,7 @@ class EbicsXfer(models.TransientModel):
if not client:
err_cnt += 1
self.note += (
_("EBICS client setup failed for connection '%s'")
self.env._("EBICS client setup failed for connection '%s'")
% self.ebics_config_id.name
)
else:
@ -269,7 +269,7 @@ class EbicsXfer(models.TransientModel):
err_cnt += 1
e = exc_info()
self.note += "\n"
self.note += _(
self.note += self.env._(
"EBICS Functional Error during download of "
"File Format %(name)s (%(order_type)s):",
name=df.name or df.description,
@ -281,7 +281,7 @@ class EbicsXfer(models.TransientModel):
err_cnt += 1
e = exc_info()
self.note += "\n"
self.note += _(
self.note += self.env._(
"EBICS Technical Error during download of "
"File Format %(name)s (%(order_type)s):",
name=df.name or df.description,
@ -292,18 +292,18 @@ class EbicsXfer(models.TransientModel):
except EbicsVerificationError:
err_cnt += 1
self.note += "\n"
self.note += _(
self.note += self.env._(
"EBICS Verification Error during download of "
"File Format %(name)s (%(order_type)s):",
name=df.name or df.description,
order_type=df.order_type,
)
self.note += "\n"
self.note += _("The EBICS response could not be verified.")
self.note += self.env._("The EBICS response could not be verified.")
except UserError as e:
err_cnt += 1
self.note += "\n"
self.note += _(
self.note += self.env._(
"Error detected during download of "
"File Format %(name)s (%(order_type)s):",
name=df.name or df.description,
@ -314,7 +314,7 @@ class EbicsXfer(models.TransientModel):
except Exception:
err_cnt += 1
self.note += "\n"
self.note += _(
self.note += self.env._(
"Unknown Error during download of "
"File Format %(name)s (%(order_type)s):",
name=df.name or df.description,
@ -334,7 +334,9 @@ class EbicsXfer(models.TransientModel):
self.note += "\n"
for f in ebics_files:
self.note += (
_("EBICS File '%s' is available for further processing.")
self.env._(
"EBICS File '%s' is available for further processing."
)
% f.name
)
self.note += "\n"
@ -343,7 +345,7 @@ class EbicsXfer(models.TransientModel):
module = __name__.split("addons.")[1].split(".")[0]
result_view = self.env.ref("%s.ebics_xfer_view_form_result" % module)
return {
"name": _("EBICS file transfer result"),
"name": self.env._("EBICS file transfer result"),
"res_id": self.id,
"view_type": "form",
"view_mode": "form",
@ -403,11 +405,14 @@ class EbicsXfer(models.TransientModel):
if OrderID:
self.note += "\n"
self.note += (
_("EBICS File has been uploaded (OrderID %s).") % OrderID
self.env._("EBICS File has been uploaded (OrderID %s).")
% OrderID
)
ef_note = _("EBICS OrderID: %s") % OrderID
ef_note = self.env._("EBICS OrderID: %s") % OrderID
if self.env.context.get("origin"):
ef_note += "\n" + _("Origin: %s") % self._context["origin"]
ef_note += (
"\n" + self.env._("Origin: %s") % self._context["origin"]
)
suffix = self.format_id.suffix
fn = self.upload_fname
if suffix and not fn.endswith(suffix):
@ -431,23 +436,23 @@ class EbicsXfer(models.TransientModel):
except EbicsFunctionalError:
e = exc_info()
self.note += "\n"
self.note += _("EBICS Functional Error:")
self.note += self.env._("EBICS Functional Error:")
self.note += "\n"
self.note += f"{e[1].message} (code: {e[1].code})"
except EbicsTechnicalError:
e = exc_info()
self.note += "\n"
self.note += _("EBICS Technical Error:")
self.note += self.env._("EBICS Technical Error:")
self.note += "\n"
self.note += f"{e[1].message} (code: {e[1].code})"
except EbicsVerificationError:
self.note += "\n"
self.note += _("EBICS Verification Error:")
self.note += self.env._("EBICS Verification Error:")
self.note += "\n"
self.note += _("The EBICS response could not be verified.")
self.note += self.env._("The EBICS response could not be verified.")
except Exception:
self.note += "\n"
self.note += _("Unknown Error")
self.note += self.env._("Unknown Error")
tb = "".join(format_exception(*exc_info()))
self.note += "\n%s" % tb
@ -478,7 +483,7 @@ class EbicsXfer(models.TransientModel):
try:
keyring = EbicsKeyRing(**keyring_params)
except (RuntimeError, ValueError) as err:
error = _("Error while accessing the EBICS Keys:")
error = self.env._("Error while accessing the EBICS Keys:")
error += "\n"
error += err.args[0]
raise UserError(error) from err
@ -507,13 +512,15 @@ class EbicsXfer(models.TransientModel):
try:
user = EbicsUser(**user_params)
except ValueError as err:
error = _("Error while accessing the EBICS UserID:")
error = self.env._("Error while accessing the EBICS UserID:")
error += "\n"
err_str = err.args[0]
error += err.args[0]
if err_str == "unknown key format":
error += "\n"
error += _("Doublecheck your EBICS Passphrase and UserID settings.")
error += self.env._(
"Doublecheck your EBICS Passphrase and UserID settings."
)
raise UserError(error) from err
# manual_approval replaced by transport_only class param in fintech 7.4
if not fintech74 and signature_class == "T":
@ -523,7 +530,7 @@ class EbicsXfer(models.TransientModel):
client = EbicsClient(bank, user, version=self.ebics_config_id.ebics_version)
except Exception:
self.note += "\n"
self.note += _("Unknown Error")
self.note += self.env._("Unknown Error")
tb = "".join(format_exception(*exc_info()))
self.note += "\n%s" % tb
client = False
@ -590,7 +597,7 @@ class EbicsXfer(models.TransientModel):
dups = self._check_duplicate_ebics_file(fn, file_format)
if dups:
raise UserError(
_(
self.env._(
"EBICS File with name '%s' has already been downloaded."
"\nPlease check this file and rename in case there is "
"no risk on duplicate transactions."

View File

@ -26,7 +26,6 @@
invisible="ebics_passphrase_store"
required="not ebics_passphrase_store"
/>
<field name="ebics_passphrase_store" invisible="1" />
<field name="date_from" />
<field name="date_to" />
<field
@ -34,7 +33,6 @@
domain="[('type', '=', 'down'), ('id', 'in', allowed_format_ids)]"
/>
<field name="order_type" />
<field name="allowed_format_ids" invisible="1" />
</group>
<footer>
<button
@ -85,13 +83,10 @@
password="True"
invisible="ebics_sig_passphrase_invisible"
/>
<field name="ebics_passphrase_store" invisible="1" />
<field name="ebics_sig_passphrase_invisible" invisible="1" />
<separator string="Select your file :" colspan="2" />
<field name="upload_data" filename="upload_fname" required="1" />
<field name="upload_fname" invisible="1" />
<field name="upload_fname_dummy" string="Upload Filename" />
<field name="upload_format_ids" invisible="1" />
<field
name="format_id"
required="1"
@ -100,7 +95,6 @@
/>
<field name="order_type" />
<field name="test_mode" invisible="order_type not in ('FUL', 'BTU')" />
<field name="allowed_format_ids" invisible="1" />
</group>
<footer>
<button