diff --git a/account_ebics/__manifest__.py b/account_ebics/__manifest__.py index 3031ab8..6b670b0 100644 --- a/account_ebics/__manifest__.py +++ b/account_ebics/__manifest__.py @@ -26,7 +26,6 @@ "wizards/ebics_admin_order.xml", "views/menu.xml", ], - "installable": True, "application": True, "external_dependencies": { "python": [ diff --git a/account_ebics/data/ebics_file_format.xml b/account_ebics/data/ebics_file_format.xml index 8c40ab0..cf8cafd 100644 --- a/account_ebics/data/ebics_file_format.xml +++ b/account_ebics/data/ebics_file_format.xml @@ -1,4 +1,4 @@ - + diff --git a/account_ebics/migrations/13.0.1.1/post-migration.py b/account_ebics/migrations/13.0.1.1/post-migration.py index 954d6c5..94783f9 100644 --- a/account_ebics/migrations/13.0.1.1/post-migration.py +++ b/account_ebics/migrations/13.0.1.1/post-migration.py @@ -3,7 +3,7 @@ import os -from openupgradelib import openupgrade # pylint: disable=W7936 +from openupgradelib import openupgrade # pylint: disable=E0401 @openupgrade.migrate() diff --git a/account_ebics/models/account_journal.py b/account_ebics/models/account_journal.py index 333a8e6..7db3ca1 100644 --- a/account_ebics/models/account_journal.py +++ b/account_ebics/models/account_journal.py @@ -11,13 +11,13 @@ class AccountJournal(models.Model): comodel_name="ebics.config", relation="account_journal_ebics_config_rel", readonly=True, - string="Ebics Configs", + string="EBICS Configs", ) ebics_config_id = fields.Many2one( comodel_name="ebics.config", compute="_compute_ebics_config_id", compute_sudo=True, - string="Ebics Config", + string="EBICS Config", ) @api.depends("ebics_config_ids") diff --git a/account_ebics/models/ebics_config.py b/account_ebics/models/ebics_config.py index 7da7e4d..b75d1a7 100644 --- a/account_ebics/models/ebics_config.py +++ b/account_ebics/models/ebics_config.py @@ -8,7 +8,7 @@ import re from odoo import api, fields, models from odoo.exceptions import UserError -_logger = logging.getLogger(__name__) +_logger = logging.getLogger(__name__) # lint-ignore=unused-logger class EbicsConfig(models.Model): @@ -160,13 +160,12 @@ class EbicsConfig(models.Model): for rec in self: rec.company_ids = rec.journal_ids.mapped("company_id") - def unlink(self): - for ebics_config in self: - if ebics_config.state == "active": - raise UserError( - self.env._("You cannot remove active EBICS configurations.") - ) - return super().unlink() + @api.ondelete(at_uninstall=False) + def _unlink_except_active(self): + if any(rec.state == "active" for rec in self): + raise UserError( + self.env._("You cannot remove active EBICS configurations.") + ) def set_to_draft(self): return self.write({"state": "draft"}) @@ -199,8 +198,8 @@ class EbicsConfig(models.Model): if not os.path.exists(dirname): raise UserError( self.env._( - "EBICS Keys Root Directory %s is not available." - "\nPlease contact your system administrator." + "EBICS Keys Root Directory %(dir)s is not available." + "\nPlease contact your system administrator.", + dir=dirname, ) - % dirname ) diff --git a/account_ebics/models/ebics_file.py b/account_ebics/models/ebics_file.py index 9106e70..33f80ec 100644 --- a/account_ebics/models/ebics_file.py +++ b/account_ebics/models/ebics_file.py @@ -9,12 +9,12 @@ from traceback import format_exception from lxml import etree -from odoo import fields, models +from odoo import api, fields, models from odoo.exceptions import UserError from odoo.addons.base.models.res_bank import sanitize_account_number -_logger = logging.getLogger(__name__) +_logger = logging.getLogger(__name__) # lint-ignore=unused-logger DUP_CHECK_FORMATS = ["cfonb120", "camt053"] @@ -63,7 +63,6 @@ class EbicsFile(models.Model): ) user_id = fields.Many2one( comodel_name="res.users", - string="User", default=lambda self: self.env.user, readonly=True, ) @@ -91,13 +90,16 @@ class EbicsFile(models.Model): help="Companies sharing this EBICS file.", ) + @api.ondelete(at_uninstall=False) + def _unlink_except_done(self): + if any(rec.state == "done" for rec in self): + raise UserError( + self.env._("You can only remove EBICS files in state 'Draft'.") + ) + def unlink(self): ff_methods = self._file_format_methods() for ebics_file in self: - if ebics_file.state == "done": - 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: @@ -385,8 +387,7 @@ class EbicsFile(models.Model): file_data = base64.b64decode(self.data).replace(b"\n", b"").replace(b"\r", b"") if len(file_data) % 120: message = self.env._( - "Incorrect CFONB120 file:\n" - "the file is not divisible in 120 char lines" + "Incorrect CFONB120 file:\nthe file is not divisible in 120 char lines" ) res["notifications"].append({"type": "error", "message": message}) return datas @@ -650,7 +651,7 @@ class EbicsFile(models.Model): self.env._( "The current version of the 'account_ebics' module " "has no support to automatically process EBICS files " - "with format %s." + "with format %s.", + self.format_id.name, ) - % self.format_id.name ) diff --git a/account_ebics/models/ebics_userid.py b/account_ebics/models/ebics_userid.py index d9de5d3..4aef532 100644 --- a/account_ebics/models/ebics_userid.py +++ b/account_ebics/models/ebics_userid.py @@ -69,8 +69,7 @@ class EbicsUserID(models.Model): string="Users", required=True, domain=[("share", "=", False)], - help="Users who are allowed to use this EBICS UserID for " - " bank transactions.", + help="Users who are allowed to use this EBICS UserID for bank transactions.", ) signature_class = fields.Selection( selection=[("E", "Single signature"), ("T", "Transport signature")], @@ -149,7 +148,7 @@ class EbicsUserID(models.Model): # create self-signed X.509 certificates ebics_key_x509 = fields.Boolean( string="X509 support", - help="Set this flag in order to work with " "self-signed X.509 certificates", + help="Set this flag in order to work with self-signed X.509 certificates", ) ebics_key_x509_dn_cn = fields.Char( string="Common Name [CN]", @@ -417,7 +416,7 @@ class EbicsUserID(models.Model): if not ebics_config_bank: raise UserError( self.env._( - "No bank defined for the financial journal " "of the EBICS Config" + "No bank defined for the financial journal of the EBICS Config" ) ) try: @@ -476,8 +475,7 @@ class EbicsUserID(models.Model): if cc in ["FR", "DE"]: lang = cc else: - lang = self.env.user.lang or self.env["res.lang"].search([])[0].code - lang = lang[:2] + lang = self.env.user.lang[:2] lang = lang.lower() lang = lang if lang in INI_LETTER_LANGS else "en" fn_date = fields.Date.today().isoformat() diff --git a/account_ebics/security/ebics_security.xml b/account_ebics/security/ebics_security.xml index f55664d..fef2c38 100644 --- a/account_ebics/security/ebics_security.xml +++ b/account_ebics/security/ebics_security.xml @@ -1,6 +1,6 @@ - + - + EBICS Manager diff --git a/account_ebics/views/ebics_config_views.xml b/account_ebics/views/ebics_config_views.xml index 0982a20..af5345a 100644 --- a/account_ebics/views/ebics_config_views.xml +++ b/account_ebics/views/ebics_config_views.xml @@ -1,4 +1,4 @@ - + ebics.config.list diff --git a/account_ebics/views/ebics_file_format_views.xml b/account_ebics/views/ebics_file_format_views.xml index 99fc173..46a23a6 100644 --- a/account_ebics/views/ebics_file_format_views.xml +++ b/account_ebics/views/ebics_file_format_views.xml @@ -1,4 +1,4 @@ - + ebics.file.format.search diff --git a/account_ebics/views/ebics_file_views.xml b/account_ebics/views/ebics_file_views.xml index bc8aa72..ca0d782 100644 --- a/account_ebics/views/ebics_file_views.xml +++ b/account_ebics/views/ebics_file_views.xml @@ -1,4 +1,4 @@ - + ebics.file.search @@ -81,7 +81,7 @@ ebics.file.form ebics.file - 1 +
@@ -177,7 +177,7 @@ ebics.file.process.result ebics.file - 100 + diff --git a/account_ebics/views/ebics_userid_views.xml b/account_ebics/views/ebics_userid_views.xml index 152caca..272e296 100644 --- a/account_ebics/views/ebics_userid_views.xml +++ b/account_ebics/views/ebics_userid_views.xml @@ -1,4 +1,4 @@ - + ebics.userid.list diff --git a/account_ebics/views/menu.xml b/account_ebics/views/menu.xml index 5a92812..b77f1f8 100644 --- a/account_ebics/views/menu.xml +++ b/account_ebics/views/menu.xml @@ -1,4 +1,4 @@ - + + EBICS Administrative Order ebics.admin.order - 1 + 1 @@ -31,7 +31,7 @@ EBICS Administrative Order result ebics.admin.order - 2 + diff --git a/account_ebics/wizards/ebics_change_passphrase.xml b/account_ebics/wizards/ebics_change_passphrase.xml index 549ca4e..67e2af4 100644 --- a/account_ebics/wizards/ebics_change_passphrase.xml +++ b/account_ebics/wizards/ebics_change_passphrase.xml @@ -1,9 +1,9 @@ - + EBICS Keys Change Passphrase ebics.change.passphrase - 1 + @@ -40,7 +40,7 @@ EBICS Keys Change Passphrase ebics.change.passphrase - 2 + diff --git a/account_ebics/wizards/ebics_xfer.py b/account_ebics/wizards/ebics_xfer.py index 56a1ced..215c476 100644 --- a/account_ebics/wizards/ebics_xfer.py +++ b/account_ebics/wizards/ebics_xfer.py @@ -224,9 +224,9 @@ class EbicsXfer(models.TransientModel): client = self._setup_client() if not client: err_cnt += 1 - self.note += ( - self.env._("EBICS client setup failed for connection '%s'") - % self.ebics_config_id.name + self.note += self.env._( + "EBICS client setup failed for connection '%s'", + self.ebics_config_id.name, ) else: download_formats = ( @@ -336,11 +336,8 @@ class EbicsXfer(models.TransientModel): if ebics_files: self.note += "\n" for f in ebics_files: - self.note += ( - self.env._( - "EBICS File '%s' is available for further processing." - ) - % f.name + self.note += self.env._( + "EBICS File '%s' is available for further processing.", f.name ) self.note += "\n" @@ -406,9 +403,8 @@ class EbicsXfer(models.TransientModel): OrderID = client.upload(order_type, upload_data) if OrderID: self.note += "\n" - self.note += ( - self.env._("EBICS File has been uploaded (OrderID %s).") - % OrderID + self.note += self.env._( + "EBICS File has been uploaded (OrderID %s).", OrderID ) ef_note = "" if self.env.context.get("origin"): @@ -619,9 +615,9 @@ class EbicsXfer(models.TransientModel): 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." + "no risk on duplicate transactions.", + fn, ) - % fn ) data = base64.encodebytes(data) ef_vals = { diff --git a/account_ebics/wizards/ebics_xfer.xml b/account_ebics/wizards/ebics_xfer.xml index c7d838c..a08e150 100644 --- a/account_ebics/wizards/ebics_xfer.xml +++ b/account_ebics/wizards/ebics_xfer.xml @@ -1,9 +1,9 @@ - + EBICS File Download ebics.xfer - 1 + @@ -55,7 +55,7 @@ EBICS File Upload ebics.xfer - 1 + @@ -120,7 +120,7 @@ EBICS File Transfer ebics.xfer - 2 + @@ -148,7 +148,7 @@ Mark EBICS files as Downloaded ebics.xfer - 1 +