mirror of
https://github.com/brain-tec/account_ebics.git
synced 2026-11-06 10:00:39 +00:00
[IMP] addons-repo-template v9.2.1
This commit is contained in:
1 parent
e4c40c373e
commit
296695f97a
21 files changed
+188
-291
No files matched your search
@@ -8,7 +8,7 @@ _logger = logging.getLogger(__name__)
|
||||
try:
|
||||
from . import models
|
||||
from . import wizards
|
||||
except Exception:
|
||||
except Exception: # noqa: BLE001 - the module must load without fintech
|
||||
_logger.warning("Import Error, check if fintech lib has been installed")
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ def _ebics_config_upgrade(env, version):
|
||||
if os.path.isfile(keys_fn_old):
|
||||
keys_fn = ebics_keys_root + "/" + cfg_data["ebics_user"] + "_keys"
|
||||
os.rename(keys_fn_old, keys_fn)
|
||||
state = cfg_data["state"] == "active" and "confirm" or "draft"
|
||||
state = (cfg_data["state"] == "active" and "confirm") or "draft"
|
||||
cfg.write(
|
||||
{
|
||||
"company_ids": [(6, 0, [cfg_data["company_id"]])],
|
||||
|
||||
@@ -127,7 +127,7 @@ class EbicsConfig(models.Model):
|
||||
|
||||
@api.model
|
||||
def _default_ebics_keys(self):
|
||||
return "/".join(["/etc/odoo/ebics_keys", self._cr.dbname])
|
||||
return f"/etc/odoo/ebics_keys/{self._cr.dbname}"
|
||||
|
||||
@api.constrains("ebics_key_bitlength")
|
||||
def _check_ebics_key_bitlength(self):
|
||||
@@ -185,9 +185,8 @@ class EbicsConfig(models.Model):
|
||||
if c == "Z":
|
||||
o_list[-i] = "0"
|
||||
continue
|
||||
else:
|
||||
o_list[-i] = chr(ord(c) + 1)
|
||||
break
|
||||
o_list[-i] = chr(ord(c) + 1)
|
||||
break
|
||||
next_order_number = "".join(o_list)
|
||||
if next_order_number == "ZZZZ":
|
||||
next_order_number = "A000"
|
||||
|
||||
@@ -225,9 +225,8 @@ class EbicsFile(models.Model):
|
||||
journal_currency = jrnl.currency_id or jrnl.company_id.currency_id
|
||||
if journal_currency != currency:
|
||||
continue
|
||||
else:
|
||||
journal = jrnl
|
||||
break
|
||||
journal = jrnl
|
||||
break
|
||||
|
||||
if not journal:
|
||||
message = self.env._(
|
||||
@@ -301,7 +300,7 @@ class EbicsFile(models.Model):
|
||||
self.note_process += self.env._(
|
||||
"%(st_cnt)s bank statement%(sp)s been imported: ",
|
||||
st_cnt=st_cnt,
|
||||
sp=st_cnt == 1 and self.env._(" has") or self.env._("s have"),
|
||||
sp=(st_cnt == 1 and self.env._(" has")) or self.env._("s have"),
|
||||
)
|
||||
self.note_process += "\n"
|
||||
for statement in statements:
|
||||
@@ -392,9 +391,7 @@ class EbicsFile(models.Model):
|
||||
res["notifications"].append({"type": "error", "message": message})
|
||||
return datas
|
||||
|
||||
lines = []
|
||||
for i in range(0, len(file_data), 120):
|
||||
lines.append(file_data[i : i + 120])
|
||||
lines = [file_data[i : i + 120] for i in range(0, len(file_data), 120)]
|
||||
|
||||
st_lines = b""
|
||||
transactions = False
|
||||
@@ -488,11 +485,12 @@ class EbicsFile(models.Model):
|
||||
try:
|
||||
with self.env.cr.savepoint():
|
||||
self._create_bank_statement_oca(res, st_data)
|
||||
except UserError as e:
|
||||
except UserError as e: # noqa: PERF203
|
||||
res["notifications"].append(
|
||||
{"type": "error", "message": "".join(e.args)}
|
||||
)
|
||||
except Exception:
|
||||
# Each statement fails alone; the traceback is reported to the user
|
||||
except Exception: # noqa: BLE001
|
||||
tb = "".join(format_exception(*exc_info()))
|
||||
res["notifications"].append({"type": "error", "message": tb})
|
||||
|
||||
@@ -514,7 +512,7 @@ class EbicsFile(models.Model):
|
||||
try:
|
||||
self._create_bank_statement_oe(res, st_data)
|
||||
self.env.cr.commit() # pylint: disable=E8102
|
||||
except UserError as e:
|
||||
except UserError as e: # noqa: PERF203
|
||||
msg = "".join(e.args)
|
||||
msg += "\n"
|
||||
msg += self.env._(
|
||||
@@ -522,7 +520,8 @@ class EbicsFile(models.Model):
|
||||
nr=st_data["acc_number"],
|
||||
)
|
||||
res["notifications"].append({"type": "error", "message": msg})
|
||||
except Exception:
|
||||
# Each statement fails alone; the traceback is reported to the user
|
||||
except Exception: # noqa: BLE001
|
||||
tb = "".join(format_exception(*exc_info()))
|
||||
res["notifications"].append({"type": "error", "message": tb})
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ class EbicsFileFormat(models.Model):
|
||||
@api.depends("ebics_version", "name", "btf_message", "description")
|
||||
def _compute_display_name(self):
|
||||
for rec in self:
|
||||
name = rec.ebics_version == "2" and rec.name or rec.btf_message
|
||||
name = (rec.ebics_version == "2" and rec.name) or rec.btf_message
|
||||
if rec.description:
|
||||
name += " - " + rec.description
|
||||
rec.display_name = name
|
||||
@@ -38,7 +38,7 @@ class EbicsBank(EbicsBank):
|
||||
The OrderID must be a string between 'A000' and 'ZZZZ' and
|
||||
unique for each partner id.
|
||||
"""
|
||||
return hasattr(self, "_order_number") and self._order_number or "A000"
|
||||
return (hasattr(self, "_order_number") and self._order_number) or "A000"
|
||||
|
||||
|
||||
class EbicsUserID(models.Model):
|
||||
@@ -216,7 +216,9 @@ class EbicsUserID(models.Model):
|
||||
rec.ebics_passphrase_store_readonly = True
|
||||
if rec.state == "draft":
|
||||
rec.ebics_passphrase_required = True
|
||||
rec.ebics_passphrase_invisible = rec.ebics_keys_found and True or False
|
||||
rec.ebics_passphrase_invisible = (
|
||||
rec.ebics_keys_found and True
|
||||
) or False
|
||||
rec.ebics_passphrase_store_readonly = False
|
||||
elif rec.state == "init":
|
||||
rec.ebics_passphrase_required = False
|
||||
@@ -289,9 +291,8 @@ class EbicsUserID(models.Model):
|
||||
keyring["#USER"]
|
||||
except ValueError as err: # noqa: F841
|
||||
raise UserError(self.env._("Passphrase mismatch.")) # noqa: B904
|
||||
else:
|
||||
if self.state != "draft":
|
||||
self.ebics_passphrase = False
|
||||
elif self.state != "draft":
|
||||
self.ebics_passphrase = False
|
||||
|
||||
@api.onchange("swift_3skey")
|
||||
def _onchange_swift_3skey(self):
|
||||
@@ -479,7 +480,7 @@ class EbicsUserID(models.Model):
|
||||
lang = lang.lower()
|
||||
lang = lang if lang in INI_LETTER_LANGS else "en"
|
||||
fn_date = fields.Date.today().isoformat()
|
||||
fn = "_".join([self.ebics_config_id.ebics_host, "ini_letter", fn_date]) + ".pdf"
|
||||
fn = f"{self.ebics_config_id.ebics_host}_ini_letter_{fn_date}" + ".pdf"
|
||||
letter = user.create_ini_letter(bankname=ebics_config_bank.name, lang=lang)
|
||||
vals = {
|
||||
"ebics_ini_letter": base64.encodebytes(letter),
|
||||
@@ -548,10 +549,7 @@ class EbicsUserID(models.Model):
|
||||
|
||||
public_bank_keys = public_bank_keys.encode()
|
||||
fn_date = fields.Date.today().isoformat()
|
||||
fn = (
|
||||
"_".join([self.ebics_config_id.ebics_host, "public_bank_keys", fn_date])
|
||||
+ ".txt"
|
||||
)
|
||||
fn = f"{self.ebics_config_id.ebics_host}_public_bank_keys_{fn_date}" + ".txt"
|
||||
vals = {
|
||||
"ebics_public_bank_keys": base64.encodebytes(public_bank_keys),
|
||||
"ebics_public_bank_keys_fn": fn,
|
||||
|
||||
@@ -24,8 +24,7 @@ try:
|
||||
fintech_register_users = (
|
||||
fintech_register_users
|
||||
and [x.strip() for x in fintech_register_users.split(",")]
|
||||
or None
|
||||
)
|
||||
) or None
|
||||
fintech.cryptolib = "cryptography"
|
||||
fintech.register(
|
||||
name=fintech_register_name,
|
||||
@@ -38,7 +37,7 @@ except RuntimeError as e:
|
||||
else:
|
||||
_logger.error(str(e))
|
||||
fintech.register()
|
||||
except Exception:
|
||||
except Exception: # noqa: BLE001 - logged with the traceback, then retried
|
||||
msg = "fintech.register error"
|
||||
tb = "".join(format_exception(*exc_info()))
|
||||
msg += f"\n{tb}"
|
||||
|
||||
@@ -70,8 +70,7 @@ class EbicsChangePassphrase(models.TransientModel):
|
||||
passphrase = (
|
||||
self.ebics_userid_id.ebics_passphrase_store
|
||||
and self.ebics_userid_id.ebics_passphrase
|
||||
or self.old_pass
|
||||
)
|
||||
) or self.old_pass
|
||||
try:
|
||||
keyring_params = {
|
||||
"keys": self.ebics_userid_id.ebics_keys_fn,
|
||||
|
||||
@@ -37,7 +37,7 @@ class EbicsBank(EbicsBank):
|
||||
The OrderID must be a string between 'A000' and 'ZZZZ' and
|
||||
unique for each partner id.
|
||||
"""
|
||||
return hasattr(self, "_order_number") and self._order_number or "A000"
|
||||
return (hasattr(self, "_order_number") and self._order_number) or "A000"
|
||||
|
||||
|
||||
class EbicsXfer(models.TransientModel):
|
||||
@@ -109,8 +109,7 @@ class EbicsXfer(models.TransientModel):
|
||||
)
|
||||
if cfg and len(cfg) == 1:
|
||||
return cfg
|
||||
else:
|
||||
return cfg_mod
|
||||
return cfg_mod
|
||||
|
||||
def _compute_ebics_sig_passphrase_invisible(self):
|
||||
for rec in self:
|
||||
@@ -236,8 +235,8 @@ class EbicsXfer(models.TransientModel):
|
||||
)
|
||||
)
|
||||
ebics_files = self.env["ebics.file"]
|
||||
date_from = self.date_from and self.date_from.isoformat() or None
|
||||
date_to = self.date_to and self.date_to.isoformat() or None
|
||||
date_from = (self.date_from and self.date_from.isoformat()) or None
|
||||
date_to = (self.date_to and self.date_to.isoformat()) or None
|
||||
for df in download_formats:
|
||||
success = False
|
||||
try:
|
||||
@@ -314,7 +313,8 @@ class EbicsXfer(models.TransientModel):
|
||||
)
|
||||
self.note += "\n"
|
||||
self.note += " ".join(e.args)
|
||||
except Exception:
|
||||
# Reported to the user in the note
|
||||
except Exception: # noqa: BLE001
|
||||
err_cnt += 1
|
||||
self.note += "\n"
|
||||
self.note += self.env._(
|
||||
@@ -412,7 +412,7 @@ class EbicsXfer(models.TransientModel):
|
||||
suffix = self.format_id.suffix
|
||||
fn = self.upload_fname
|
||||
if suffix and not fn.endswith(suffix):
|
||||
fn = ".".join([fn, suffix])
|
||||
fn = f"{fn}.{suffix}"
|
||||
ef_vals = {
|
||||
"name": self.upload_fname,
|
||||
"data": self.upload_data,
|
||||
@@ -449,7 +449,8 @@ class EbicsXfer(models.TransientModel):
|
||||
self.note += self.env._("EBICS Verification Error:")
|
||||
self.note += "\n"
|
||||
self.note += self.env._("The EBICS response could not be verified.")
|
||||
except Exception:
|
||||
# Reported to the user in the note, with the traceback
|
||||
except Exception: # noqa: BLE001
|
||||
self.note += "\n"
|
||||
self.note += self.env._("Unknown Error")
|
||||
tb = "".join(format_exception(*exc_info()))
|
||||
@@ -523,7 +524,7 @@ class EbicsXfer(models.TransientModel):
|
||||
# manual_approval replaced by transport_only class param in fintech 7.4
|
||||
fintech74 = hasattr(EbicsUser, "transport_only")
|
||||
if fintech74:
|
||||
user_params["transport_only"] = signature_class == "T" and True or False
|
||||
user_params["transport_only"] = (signature_class == "T" and True) or False
|
||||
try:
|
||||
user = EbicsUser(**user_params)
|
||||
except ValueError as err:
|
||||
@@ -543,7 +544,8 @@ class EbicsXfer(models.TransientModel):
|
||||
|
||||
try:
|
||||
client = EbicsClient(bank, user, version=self.ebics_config_id.ebics_version)
|
||||
except Exception:
|
||||
# Reported to the user in the note, with the traceback
|
||||
except Exception: # noqa: BLE001
|
||||
self.note += "\n"
|
||||
self.note += self.env._("Unknown Error")
|
||||
tb = "".join(format_exception(*exc_info()))
|
||||
@@ -608,7 +610,7 @@ class EbicsXfer(models.TransientModel):
|
||||
|
||||
suffix = file_format.suffix
|
||||
if suffix and not fn.endswith(suffix):
|
||||
fn = ".".join([fn, suffix])
|
||||
fn = f"{fn}.{suffix}"
|
||||
dups = self._check_duplicate_ebics_file(fn, file_format)
|
||||
if dups:
|
||||
raise UserError(
|
||||
@@ -627,7 +629,7 @@ class EbicsXfer(models.TransientModel):
|
||||
"date_from": self.date_from,
|
||||
"date_to": self.date_to,
|
||||
"format_id": file_format.id,
|
||||
"state": file_format.download_process_method and "draft" or "done",
|
||||
"state": (file_format.download_process_method and "draft") or "done",
|
||||
"user_id": self._uid,
|
||||
"ebics_userid_id": self.ebics_userid_id.id,
|
||||
"company_ids": self.ebics_config_id.company_ids.ids,
|
||||
@@ -656,9 +658,8 @@ class EbicsXfer(models.TransientModel):
|
||||
break
|
||||
if c == "Z":
|
||||
continue
|
||||
else:
|
||||
o_list[-i] = chr(ord(c) + 1)
|
||||
break
|
||||
o_list[-i] = chr(ord(c) + 1)
|
||||
break
|
||||
next_nr = "".join(o_list)
|
||||
if next_nr == "ZZZZ":
|
||||
next_nr = "A000"
|
||||
|
||||
Reference in new issue
Block a user