diff --git a/account_ebics/__manifest__.py b/account_ebics/__manifest__.py index 5b9b51a..ca96480 100644 --- a/account_ebics/__manifest__.py +++ b/account_ebics/__manifest__.py @@ -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", diff --git a/account_ebics/models/ebics_config.py b/account_ebics/models/ebics_config.py index 5582092..5aca89c 100644 --- a/account_ebics/models/ebics_config.py +++ b/account_ebics/models/ebics_config.py @@ -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." ) diff --git a/account_ebics/models/ebics_file.py b/account_ebics/models/ebics_file.py index 66f2af8..cc5dd45 100644 --- a/account_ebics/models/ebics_file.py +++ b/account_ebics/models/ebics_file.py @@ -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." diff --git a/account_ebics/models/ebics_userid.py b/account_ebics/models/ebics_userid.py index bf0b95f..bba605b 100644 --- a/account_ebics/models/ebics_userid.py +++ b/account_ebics/models/ebics_userid.py @@ -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", diff --git a/account_ebics/views/ebics_config_views.xml b/account_ebics/views/ebics_config_views.xml index 054586b..7f15850 100644 --- a/account_ebics/views/ebics_config_views.xml +++ b/account_ebics/views/ebics_config_views.xml @@ -1,16 +1,16 @@ - - ebics.config.tree + + ebics.config.list ebics.config - + - + @@ -39,7 +39,6 @@ /> - - @@ -87,7 +85,7 @@ EBICS Configuration ebics.config - tree,form + list,form {'active_test': False} diff --git a/account_ebics/views/ebics_file_format_views.xml b/account_ebics/views/ebics_file_format_views.xml index 25b81e7..7699a69 100644 --- a/account_ebics/views/ebics_file_format_views.xml +++ b/account_ebics/views/ebics_file_format_views.xml @@ -1,18 +1,18 @@ - - ebics.file.format.tree + + ebics.file.format.list ebics.file.format - + - + @@ -68,7 +68,7 @@ EBICS File Formats ebics.file.format - tree,form + list,form diff --git a/account_ebics/views/ebics_file_views.xml b/account_ebics/views/ebics_file_views.xml index 48df313..465ccbb 100644 --- a/account_ebics/views/ebics_file_views.xml +++ b/account_ebics/views/ebics_file_views.xml @@ -34,11 +34,11 @@ - - ebics.file.tree + + ebics.file.list ebics.file - + @@ -51,7 +51,7 @@ widget="many2many_tags" groups="base.group_multi_company" /> - + @@ -140,16 +140,16 @@ EBICS Download Files ir.actions.act_window ebics.file - tree,form + list,form [('type','=','down')] - + - tree - + list + @@ -162,11 +162,11 @@ - - ebics.file.tree + + ebics.file.list ebics.file - + @@ -177,7 +177,7 @@ widget="many2many_tags" groups="base.group_multi_company" /> - + @@ -230,16 +230,16 @@ EBICS Upload Files ir.actions.act_window ebics.file - tree,form + list,form [('type','=','up')] - + - tree - + list + diff --git a/account_ebics/views/ebics_userid_views.xml b/account_ebics/views/ebics_userid_views.xml index 61447be..03ef2c7 100644 --- a/account_ebics/views/ebics_userid_views.xml +++ b/account_ebics/views/ebics_userid_views.xml @@ -1,16 +1,16 @@ - - ebics.userid.tree + + ebics.userid.list ebics.userid - + - + @@ -82,16 +82,6 @@ /> - - - - - - - - - - diff --git a/account_ebics/wizards/ebics_admin_order.py b/account_ebics/wizards/ebics_admin_order.py index d0ffedf..8d4b9a9 100644 --- a/account_ebics/wizards/ebics_admin_order.py +++ b/account_ebics/wizards/ebics_admin_order.py @@ -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", diff --git a/account_ebics/wizards/ebics_change_passphrase.py b/account_ebics/wizards/ebics_change_passphrase.py index 05b05b6..728dd0c 100644 --- a/account_ebics/wizards/ebics_change_passphrase.py +++ b/account_ebics/wizards/ebics_change_passphrase.py @@ -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", diff --git a/account_ebics/wizards/ebics_change_passphrase.xml b/account_ebics/wizards/ebics_change_passphrase.xml index 1a98dd9..b556072 100644 --- a/account_ebics/wizards/ebics_change_passphrase.xml +++ b/account_ebics/wizards/ebics_change_passphrase.xml @@ -18,9 +18,6 @@ - - -