mirror of
https://github.com/brain-tec/account_ebics.git
synced 2026-12-01 14:01:15 +00:00
[IMP] fix pre-commit errors
This commit is contained in:
1 parent
d7763786a2
commit
3cb3a50d16
8 files changed
+35
-45
No files matched your search
@@ -8,7 +8,7 @@ _logger = logging.getLogger(__name__)
|
|||||||
try:
|
try:
|
||||||
from . import models
|
from . import models
|
||||||
from . import wizards
|
from . import wizards
|
||||||
except Exception:
|
except ImportError:
|
||||||
_logger.warning("Import Error, check if fintech lib has been installed")
|
_logger.warning("Import Error, check if fintech lib has been installed")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class EbicsConfig(models.Model):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _default_ebics_keys(self):
|
def _default_ebics_keys(self):
|
||||||
return "/".join(["/etc/odoo/ebics_keys", self.env.cr.dbname])
|
return f"/etc/odoo/ebics_keys/{self.env.cr.dbname}"
|
||||||
|
|
||||||
@api.constrains("ebics_key_bitlength")
|
@api.constrains("ebics_key_bitlength")
|
||||||
def _check_ebics_key_bitlength(self):
|
def _check_ebics_key_bitlength(self):
|
||||||
@@ -185,9 +185,8 @@ class EbicsConfig(models.Model):
|
|||||||
if c == "Z":
|
if c == "Z":
|
||||||
o_list[-i] = "0"
|
o_list[-i] = "0"
|
||||||
continue
|
continue
|
||||||
else:
|
o_list[-i] = chr(ord(c) + 1)
|
||||||
o_list[-i] = chr(ord(c) + 1)
|
break
|
||||||
break
|
|
||||||
next_order_number = "".join(o_list)
|
next_order_number = "".join(o_list)
|
||||||
if next_order_number == "ZZZZ":
|
if next_order_number == "ZZZZ":
|
||||||
next_order_number = "A000"
|
next_order_number = "A000"
|
||||||
|
|||||||
@@ -221,9 +221,8 @@ class EbicsFile(models.Model):
|
|||||||
journal_currency = jrnl.currency_id or jrnl.company_id.currency_id
|
journal_currency = jrnl.currency_id or jrnl.company_id.currency_id
|
||||||
if journal_currency != currency:
|
if journal_currency != currency:
|
||||||
continue
|
continue
|
||||||
else:
|
journal = jrnl
|
||||||
journal = jrnl
|
break
|
||||||
break
|
|
||||||
|
|
||||||
if not journal:
|
if not journal:
|
||||||
message = self.env._(
|
message = self.env._(
|
||||||
@@ -297,7 +296,7 @@ class EbicsFile(models.Model):
|
|||||||
self.note_process += self.env._(
|
self.note_process += self.env._(
|
||||||
"%(st_cnt)s bank statement%(sp)s been imported: ",
|
"%(st_cnt)s bank statement%(sp)s been imported: ",
|
||||||
st_cnt=st_cnt,
|
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"
|
self.note_process += "\n"
|
||||||
for statement in statements:
|
for statement in statements:
|
||||||
@@ -388,9 +387,7 @@ class EbicsFile(models.Model):
|
|||||||
res["notifications"].append({"type": "error", "message": message})
|
res["notifications"].append({"type": "error", "message": message})
|
||||||
return datas
|
return datas
|
||||||
|
|
||||||
lines = []
|
lines = [file_data[i : i + 120] for i in range(0, len(file_data), 120)]
|
||||||
for i in range(0, len(file_data), 120):
|
|
||||||
lines.append(file_data[i : i + 120])
|
|
||||||
|
|
||||||
st_lines = b""
|
st_lines = b""
|
||||||
transactions = False
|
transactions = False
|
||||||
@@ -488,7 +485,7 @@ class EbicsFile(models.Model):
|
|||||||
res["notifications"].append(
|
res["notifications"].append(
|
||||||
{"type": "error", "message": "".join(e.args)}
|
{"type": "error", "message": "".join(e.args)}
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception: # noqa: BLE001
|
||||||
tb = "".join(format_exception(*exc_info()))
|
tb = "".join(format_exception(*exc_info()))
|
||||||
res["notifications"].append({"type": "error", "message": tb})
|
res["notifications"].append({"type": "error", "message": tb})
|
||||||
|
|
||||||
@@ -518,7 +515,7 @@ class EbicsFile(models.Model):
|
|||||||
nr=st_data["acc_number"],
|
nr=st_data["acc_number"],
|
||||||
)
|
)
|
||||||
res["notifications"].append({"type": "error", "message": msg})
|
res["notifications"].append({"type": "error", "message": msg})
|
||||||
except Exception:
|
except Exception: # noqa: BLE001
|
||||||
tb = "".join(format_exception(*exc_info()))
|
tb = "".join(format_exception(*exc_info()))
|
||||||
res["notifications"].append({"type": "error", "message": tb})
|
res["notifications"].append({"type": "error", "message": tb})
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ class EbicsFileFormat(models.Model):
|
|||||||
@api.depends("ebics_version", "name", "btf_message", "description")
|
@api.depends("ebics_version", "name", "btf_message", "description")
|
||||||
def _compute_display_name(self):
|
def _compute_display_name(self):
|
||||||
for rec in 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:
|
if rec.description:
|
||||||
name += " - " + rec.description
|
name += " - " + rec.description
|
||||||
rec.display_name = name
|
rec.display_name = name
|
||||||
@@ -38,7 +38,7 @@ class EbicsBank(EbicsBank):
|
|||||||
The OrderID must be a string between 'A000' and 'ZZZZ' and
|
The OrderID must be a string between 'A000' and 'ZZZZ' and
|
||||||
unique for each partner id.
|
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):
|
class EbicsUserID(models.Model):
|
||||||
@@ -216,7 +216,9 @@ class EbicsUserID(models.Model):
|
|||||||
rec.ebics_passphrase_store_readonly = True
|
rec.ebics_passphrase_store_readonly = True
|
||||||
if rec.state == "draft":
|
if rec.state == "draft":
|
||||||
rec.ebics_passphrase_required = True
|
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
|
rec.ebics_passphrase_store_readonly = False
|
||||||
elif rec.state == "init":
|
elif rec.state == "init":
|
||||||
rec.ebics_passphrase_required = False
|
rec.ebics_passphrase_required = False
|
||||||
@@ -289,9 +291,8 @@ class EbicsUserID(models.Model):
|
|||||||
keyring["#USER"]
|
keyring["#USER"]
|
||||||
except ValueError as err: # noqa: F841
|
except ValueError as err: # noqa: F841
|
||||||
raise UserError(self.env._("Passphrase mismatch.")) # noqa: B904
|
raise UserError(self.env._("Passphrase mismatch.")) # noqa: B904
|
||||||
else:
|
elif self.state != "draft":
|
||||||
if self.state != "draft":
|
self.ebics_passphrase = False
|
||||||
self.ebics_passphrase = False
|
|
||||||
|
|
||||||
@api.onchange("swift_3skey")
|
@api.onchange("swift_3skey")
|
||||||
def _onchange_swift_3skey(self):
|
def _onchange_swift_3skey(self):
|
||||||
@@ -479,7 +480,7 @@ class EbicsUserID(models.Model):
|
|||||||
lang = lang.lower()
|
lang = lang.lower()
|
||||||
lang = lang if lang in INI_LETTER_LANGS else "en"
|
lang = lang if lang in INI_LETTER_LANGS else "en"
|
||||||
fn_date = fields.Date.today().isoformat()
|
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)
|
letter = user.create_ini_letter(bankname=ebics_config_bank.name, lang=lang)
|
||||||
vals = {
|
vals = {
|
||||||
"ebics_ini_letter": base64.encodebytes(letter),
|
"ebics_ini_letter": base64.encodebytes(letter),
|
||||||
@@ -548,10 +549,7 @@ class EbicsUserID(models.Model):
|
|||||||
|
|
||||||
public_bank_keys = public_bank_keys.encode()
|
public_bank_keys = public_bank_keys.encode()
|
||||||
fn_date = fields.Date.today().isoformat()
|
fn_date = fields.Date.today().isoformat()
|
||||||
fn = (
|
fn = f"{self.ebics_config_id.ebics_host}_public_bank_keys_{fn_date}.txt"
|
||||||
"_".join([self.ebics_config_id.ebics_host, "public_bank_keys", fn_date])
|
|
||||||
+ ".txt"
|
|
||||||
)
|
|
||||||
vals = {
|
vals = {
|
||||||
"ebics_public_bank_keys": base64.encodebytes(public_bank_keys),
|
"ebics_public_bank_keys": base64.encodebytes(public_bank_keys),
|
||||||
"ebics_public_bank_keys_fn": fn,
|
"ebics_public_bank_keys_fn": fn,
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ try:
|
|||||||
fintech_register_users = (
|
fintech_register_users = (
|
||||||
fintech_register_users
|
fintech_register_users
|
||||||
and [x.strip() for x in fintech_register_users.split(",")]
|
and [x.strip() for x in fintech_register_users.split(",")]
|
||||||
or None
|
) or None
|
||||||
)
|
|
||||||
fintech.cryptolib = "cryptography"
|
fintech.cryptolib = "cryptography"
|
||||||
fintech.register(
|
fintech.register(
|
||||||
name=fintech_register_name,
|
name=fintech_register_name,
|
||||||
@@ -38,7 +37,7 @@ except RuntimeError as e:
|
|||||||
else:
|
else:
|
||||||
_logger.error(str(e))
|
_logger.error(str(e))
|
||||||
fintech.register()
|
fintech.register()
|
||||||
except Exception:
|
except Exception: # noqa: BLE001
|
||||||
msg = "fintech.register error"
|
msg = "fintech.register error"
|
||||||
tb = "".join(format_exception(*exc_info()))
|
tb = "".join(format_exception(*exc_info()))
|
||||||
msg += f"\n{tb}"
|
msg += f"\n{tb}"
|
||||||
|
|||||||
@@ -70,8 +70,7 @@ class EbicsChangePassphrase(models.TransientModel):
|
|||||||
passphrase = (
|
passphrase = (
|
||||||
self.ebics_userid_id.ebics_passphrase_store
|
self.ebics_userid_id.ebics_passphrase_store
|
||||||
and self.ebics_userid_id.ebics_passphrase
|
and self.ebics_userid_id.ebics_passphrase
|
||||||
or self.old_pass
|
) or self.old_pass
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
keyring_params = {
|
keyring_params = {
|
||||||
"keys": self.ebics_userid_id.ebics_keys_fn,
|
"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
|
The OrderID must be a string between 'A000' and 'ZZZZ' and
|
||||||
unique for each partner id.
|
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):
|
class EbicsXfer(models.TransientModel):
|
||||||
@@ -109,8 +109,7 @@ class EbicsXfer(models.TransientModel):
|
|||||||
)
|
)
|
||||||
if cfg and len(cfg) == 1:
|
if cfg and len(cfg) == 1:
|
||||||
return cfg
|
return cfg
|
||||||
else:
|
return cfg_mod
|
||||||
return cfg_mod
|
|
||||||
|
|
||||||
def _compute_ebics_sig_passphrase_invisible(self):
|
def _compute_ebics_sig_passphrase_invisible(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
@@ -236,8 +235,8 @@ class EbicsXfer(models.TransientModel):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
ebics_files = self.env["ebics.file"]
|
ebics_files = self.env["ebics.file"]
|
||||||
date_from = self.date_from and self.date_from.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
|
date_to = (self.date_to and self.date_to.isoformat()) or None
|
||||||
for df in download_formats:
|
for df in download_formats:
|
||||||
success = False
|
success = False
|
||||||
try:
|
try:
|
||||||
@@ -314,7 +313,7 @@ class EbicsXfer(models.TransientModel):
|
|||||||
)
|
)
|
||||||
self.note += "\n"
|
self.note += "\n"
|
||||||
self.note += " ".join(e.args)
|
self.note += " ".join(e.args)
|
||||||
except Exception:
|
except Exception: # noqa: BLE001
|
||||||
err_cnt += 1
|
err_cnt += 1
|
||||||
self.note += "\n"
|
self.note += "\n"
|
||||||
self.note += self.env._(
|
self.note += self.env._(
|
||||||
@@ -412,7 +411,7 @@ class EbicsXfer(models.TransientModel):
|
|||||||
suffix = self.format_id.suffix
|
suffix = self.format_id.suffix
|
||||||
fn = self.upload_fname
|
fn = self.upload_fname
|
||||||
if suffix and not fn.endswith(suffix):
|
if suffix and not fn.endswith(suffix):
|
||||||
fn = ".".join([fn, suffix])
|
fn = f"{fn}.{suffix}"
|
||||||
ef_vals = {
|
ef_vals = {
|
||||||
"name": self.upload_fname,
|
"name": self.upload_fname,
|
||||||
"data": self.upload_data,
|
"data": self.upload_data,
|
||||||
@@ -449,7 +448,7 @@ class EbicsXfer(models.TransientModel):
|
|||||||
self.note += self.env._("EBICS Verification Error:")
|
self.note += self.env._("EBICS Verification Error:")
|
||||||
self.note += "\n"
|
self.note += "\n"
|
||||||
self.note += self.env._("The EBICS response could not be verified.")
|
self.note += self.env._("The EBICS response could not be verified.")
|
||||||
except Exception:
|
except Exception: # noqa: BLE001
|
||||||
self.note += "\n"
|
self.note += "\n"
|
||||||
self.note += self.env._("Unknown Error")
|
self.note += self.env._("Unknown Error")
|
||||||
tb = "".join(format_exception(*exc_info()))
|
tb = "".join(format_exception(*exc_info()))
|
||||||
@@ -523,7 +522,7 @@ class EbicsXfer(models.TransientModel):
|
|||||||
# manual_approval replaced by transport_only class param in fintech 7.4
|
# manual_approval replaced by transport_only class param in fintech 7.4
|
||||||
fintech74 = hasattr(EbicsUser, "transport_only")
|
fintech74 = hasattr(EbicsUser, "transport_only")
|
||||||
if fintech74:
|
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:
|
try:
|
||||||
user = EbicsUser(**user_params)
|
user = EbicsUser(**user_params)
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
@@ -543,7 +542,7 @@ class EbicsXfer(models.TransientModel):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
client = EbicsClient(bank, user, version=self.ebics_config_id.ebics_version)
|
client = EbicsClient(bank, user, version=self.ebics_config_id.ebics_version)
|
||||||
except Exception:
|
except Exception: # noqa: BLE001
|
||||||
self.note += "\n"
|
self.note += "\n"
|
||||||
self.note += self.env._("Unknown Error")
|
self.note += self.env._("Unknown Error")
|
||||||
tb = "".join(format_exception(*exc_info()))
|
tb = "".join(format_exception(*exc_info()))
|
||||||
@@ -608,7 +607,7 @@ class EbicsXfer(models.TransientModel):
|
|||||||
|
|
||||||
suffix = file_format.suffix
|
suffix = file_format.suffix
|
||||||
if suffix and not fn.endswith(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)
|
dups = self._check_duplicate_ebics_file(fn, file_format)
|
||||||
if dups:
|
if dups:
|
||||||
raise UserError(
|
raise UserError(
|
||||||
@@ -626,7 +625,7 @@ class EbicsXfer(models.TransientModel):
|
|||||||
"date_from": self.date_from,
|
"date_from": self.date_from,
|
||||||
"date_to": self.date_to,
|
"date_to": self.date_to,
|
||||||
"format_id": file_format.id,
|
"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.env.uid,
|
"user_id": self.env.uid,
|
||||||
"ebics_userid_id": self.ebics_userid_id.id,
|
"ebics_userid_id": self.ebics_userid_id.id,
|
||||||
"company_ids": self.ebics_config_id.company_ids.ids,
|
"company_ids": self.ebics_config_id.company_ids.ids,
|
||||||
@@ -655,9 +654,8 @@ class EbicsXfer(models.TransientModel):
|
|||||||
break
|
break
|
||||||
if c == "Z":
|
if c == "Z":
|
||||||
continue
|
continue
|
||||||
else:
|
o_list[-i] = chr(ord(c) + 1)
|
||||||
o_list[-i] = chr(ord(c) + 1)
|
break
|
||||||
break
|
|
||||||
next_nr = "".join(o_list)
|
next_nr = "".join(o_list)
|
||||||
if next_nr == "ZZZZ":
|
if next_nr == "ZZZZ":
|
||||||
next_nr = "A000"
|
next_nr = "A000"
|
||||||
|
|||||||
Reference in new issue
Block a user