[MIG] account_ebics: Migration to 19.0

This commit is contained in:
Luc De Meyer
2026-03-01 23:30:15 +01:00
parent 051c68f785
commit 71835fae7b
23 changed files with 68 additions and 372 deletions

View File

@@ -126,7 +126,7 @@ class EbicsConfig(models.Model):
@api.model
def _default_ebics_keys(self):
return "/".join(["/etc/odoo/ebics_keys", self._cr.dbname])
return "/".join(["/etc/odoo/ebics_keys", self.env.cr.dbname])
@api.constrains("ebics_key_bitlength")
def _check_ebics_key_bitlength(self):
@@ -154,6 +154,13 @@ class EbicsConfig(models.Model):
)
)
@api.ondelete(at_uninstall=False)
def _unlink_except_confirm(self):
if any(rec.state == "confirm" for rec in self):
raise UserError(
self.env._("You cannot remove active EBICS configurations.")
)
def write(self, vals):
"""
Due to the multi-company nature of the EBICS config we
@@ -175,14 +182,6 @@ class EbicsConfig(models.Model):
super(EbicsConfig, rec).write({"company_ids": updates})
return True
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()
def set_to_draft(self):
return self.write({"state": "draft"})
@@ -214,8 +213,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
)

View File

@@ -9,7 +9,7 @@ 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
@@ -23,13 +23,10 @@ class EbicsFile(models.Model):
_name = "ebics.file"
_description = "Object to store EBICS Data Files"
_order = "date desc"
_sql_constraints = [
(
"name_uniq",
"unique (name, format_id)",
"This File has already been down- or uploaded !",
)
]
_name_uniq = models.Constraint(
"unique (name, format_id)",
"This File has already been down- or uploaded !",
)
name = fields.Char(string="Filename")
data = fields.Binary(string="File", readonly=True)
@@ -63,7 +60,6 @@ class EbicsFile(models.Model):
)
user_id = fields.Many2one(
comodel_name="res.users",
string="User",
default=lambda self: self.env.user,
readonly=True,
)
@@ -85,13 +81,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:
@@ -637,7 +636,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
)

View File

@@ -475,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()