mirror of
https://github.com/brain-tec/account_ebics.git
synced 2025-08-14 14:45:36 +00:00
[IMP] account_ebics: pre-commit
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Copyright 2009-2020 Noviat.
|
||||
# Copyright 2009-2022 Noviat.
|
||||
# License LGPL-3 or later (http://www.gnu.org/licenses/lpgl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
@@ -22,7 +22,6 @@ class EbicsConfig(models.Model):
|
||||
_order = "name"
|
||||
|
||||
name = fields.Char(
|
||||
string="Name",
|
||||
readonly=True,
|
||||
states={"draft": [("readonly", False)]},
|
||||
required=True,
|
||||
@@ -131,7 +130,6 @@ class EbicsConfig(models.Model):
|
||||
)
|
||||
state = fields.Selection(
|
||||
[("draft", "Draft"), ("confirm", "Confirmed")],
|
||||
string="State",
|
||||
default="draft",
|
||||
required=True,
|
||||
readonly=True,
|
||||
@@ -144,7 +142,7 @@ class EbicsConfig(models.Model):
|
||||
"\nThis number should match the following pattern : "
|
||||
"[A-Z]{1}[A-Z0-9]{3}",
|
||||
)
|
||||
active = fields.Boolean(string="Active", default=True)
|
||||
active = fields.Boolean(default=True)
|
||||
company_ids = fields.Many2many(
|
||||
comodel_name="res.company",
|
||||
string="Companies",
|
||||
|
@@ -46,7 +46,6 @@ class EbicsFile(models.Model):
|
||||
)
|
||||
state = fields.Selection(
|
||||
[("draft", "Draft"), ("done", "Done")],
|
||||
string="State",
|
||||
default="draft",
|
||||
required=True,
|
||||
readonly=True,
|
||||
@@ -93,8 +92,7 @@ class EbicsFile(models.Model):
|
||||
|
||||
def process(self):
|
||||
self.ensure_one()
|
||||
ctx = dict(self.env.context, allowed_company_ids=self.env.user.company_ids.ids)
|
||||
self = self.with_context(ctx)
|
||||
self = self.with_context(allowed_company_ids=self.env.user.company_ids.ids)
|
||||
self.note_process = ""
|
||||
ff_methods = self._file_format_methods()
|
||||
ff = self.format_id.download_process_method
|
||||
@@ -159,11 +157,12 @@ class EbicsFile(models.Model):
|
||||
if raise_if_not_found:
|
||||
raise UserError(
|
||||
_(
|
||||
"The module to process the '%s' format is not installed "
|
||||
"The module to process the '%(ebics_format)s' format is not installed "
|
||||
"on your system. "
|
||||
"\nPlease install module '%s'"
|
||||
"\nPlease install module '%(module)s'",
|
||||
ebics_format=self.format_id.name,
|
||||
module=module,
|
||||
)
|
||||
% (self.format_id.name, module)
|
||||
)
|
||||
return False
|
||||
return True
|
||||
@@ -288,9 +287,12 @@ class EbicsFile(models.Model):
|
||||
"notifications": [],
|
||||
},
|
||||
}
|
||||
wiz_ctx = dict(self.env.context, active_model="ebics.file")
|
||||
for i, wiz_vals in enumerate(wiz_vals_list, start=1):
|
||||
wiz = self.env[wiz_model].with_context(wiz_ctx).create(wiz_vals)
|
||||
wiz = (
|
||||
self.env[wiz_model]
|
||||
.with_context(active_model="ebics.file")
|
||||
.create(wiz_vals)
|
||||
)
|
||||
res = wiz.import_file_button()
|
||||
ctx = res.get("context")
|
||||
if res.get("res_model") == "account.bank.statement.import.journal.creation":
|
||||
@@ -360,11 +362,12 @@ class EbicsFile(models.Model):
|
||||
if not found:
|
||||
raise UserError(
|
||||
_(
|
||||
"The module to process the '%s' format is not installed "
|
||||
"on your system. "
|
||||
"\nPlease install one of the following modules: \n%s."
|
||||
"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.",
|
||||
ebics_format=self.format_id.name,
|
||||
modules=", ".join([x[1] for x in modules]),
|
||||
)
|
||||
% (self.format_id.name, ", ".join([x[1] for x in modules]))
|
||||
)
|
||||
if _src == "oca":
|
||||
self._process_camt053_oca()
|
||||
@@ -386,8 +389,9 @@ class EbicsFile(models.Model):
|
||||
"notifications": [],
|
||||
},
|
||||
}
|
||||
wiz_ctx = dict(self.env.context, active_model="ebics.file")
|
||||
wiz = self.env[wiz_model].with_context(wiz_ctx).create(wiz_vals)
|
||||
wiz = (
|
||||
self.env[wiz_model].with_context(active_model="ebics.file").create(wiz_vals)
|
||||
)
|
||||
res = wiz.import_file_button()
|
||||
ctx = res.get("context")
|
||||
if res.get("res_model") == "account.bank.statement.import.journal.creation":
|
||||
@@ -418,8 +422,9 @@ class EbicsFile(models.Model):
|
||||
)
|
||||
]
|
||||
}
|
||||
ctx = dict(self.env.context, active_model="ebics.file")
|
||||
wiz = self.env[wiz_model].with_context(ctx).create(wiz_vals)
|
||||
wiz = (
|
||||
self.env[wiz_model].with_context(active_model="ebics.file").create(wiz_vals)
|
||||
)
|
||||
res = wiz.import_file()
|
||||
if res.get("res_model") == "account.bank.statement.import.journal.creation":
|
||||
if res.get("context"):
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright 2009-2020 Noviat.
|
||||
# Copyright 2009-2022 Noviat.
|
||||
# License LGPL-3 or later (http://www.gnu.org/licenses/lpgl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
@@ -22,7 +22,6 @@ class EbicsFileFormat(models.Model):
|
||||
selection=[("down", "Download"), ("up", "Upload")], required=True
|
||||
)
|
||||
order_type = fields.Char(
|
||||
string="Order Type",
|
||||
required=True,
|
||||
help="E.g. C53 (check your EBICS contract).\n"
|
||||
"For most banks in France you should use the "
|
||||
@@ -40,7 +39,6 @@ class EbicsFileFormat(models.Model):
|
||||
# move signature_class parameter so that it can be set per EBICS config
|
||||
signature_class = fields.Selection(
|
||||
selection=[("E", "Single signature"), ("T", "Transport signature")],
|
||||
string="Signature Class",
|
||||
help="Please doublecheck the security of your Odoo "
|
||||
"ERP system when using class 'E' to prevent unauthorised "
|
||||
"users to make supplier payments."
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright 2009-2020 Noviat.
|
||||
# Copyright 2009-2022 Noviat.
|
||||
# License LGPL-3 or later (http://www.gnu.org/licenses/lpgl).
|
||||
|
||||
import base64
|
||||
@@ -75,7 +75,6 @@ class EbicsUserID(models.Model):
|
||||
# Classes A and B are not yet supported.
|
||||
signature_class = fields.Selection(
|
||||
selection=[("E", "Single signature"), ("T", "Transport signature")],
|
||||
string="Signature Class",
|
||||
required=True,
|
||||
default="T",
|
||||
readonly=True,
|
||||
@@ -157,12 +156,11 @@ class EbicsUserID(models.Model):
|
||||
("to_verify", "Verification"),
|
||||
("active_keys", "Active Keys"),
|
||||
],
|
||||
string="State",
|
||||
default="draft",
|
||||
required=True,
|
||||
readonly=True,
|
||||
)
|
||||
active = fields.Boolean(string="Active", default=True)
|
||||
active = fields.Boolean(default=True)
|
||||
company_ids = fields.Many2many(
|
||||
comodel_name="res.company",
|
||||
string="Companies",
|
||||
@@ -243,11 +241,11 @@ class EbicsUserID(models.Model):
|
||||
partnerid=self.ebics_config_id.ebics_partner,
|
||||
userid=self.name,
|
||||
)
|
||||
except Exception:
|
||||
except Exception as err:
|
||||
exctype, value = exc_info()[:2]
|
||||
error = _("EBICS Initialisation Error:")
|
||||
error += "\n" + str(exctype) + "\n" + str(value)
|
||||
raise UserError(error)
|
||||
raise UserError(error) from err
|
||||
|
||||
self.ebics_config_id._check_ebics_keys()
|
||||
if not os.path.isfile(self.ebics_keys_fn):
|
||||
@@ -265,11 +263,11 @@ class EbicsUserID(models.Model):
|
||||
keyversion=self.ebics_config_id.ebics_key_version,
|
||||
bitlength=self.ebics_config_id.ebics_key_bitlength,
|
||||
)
|
||||
except Exception:
|
||||
except Exception as err:
|
||||
exctype, value = exc_info()[:2]
|
||||
error = _("EBICS Initialisation Error:")
|
||||
error += "\n" + str(exctype) + "\n" + str(value)
|
||||
raise UserError(error)
|
||||
raise UserError(error) from err
|
||||
|
||||
if self.swift_3skey and not self.ebics_key_x509:
|
||||
raise UserError(
|
||||
@@ -314,7 +312,7 @@ class EbicsUserID(models.Model):
|
||||
_logger.info("%s, EBICS INI command, OrderID=%s", self._name, OrderID)
|
||||
if ebics_version == "H003":
|
||||
self.ebics_config_id._update_order_number(OrderID)
|
||||
except URLError:
|
||||
except URLError as err:
|
||||
exctype, value = exc_info()[:2]
|
||||
tb = "".join(format_exception(*exc_info()))
|
||||
_logger.error(
|
||||
@@ -323,21 +321,22 @@ class EbicsUserID(models.Model):
|
||||
tb,
|
||||
)
|
||||
raise UserError(
|
||||
_("urlopen error:\n url '%s' - %s")
|
||||
% (self.ebics_config_id.ebics_url, str(value))
|
||||
)
|
||||
except EbicsFunctionalError:
|
||||
_("urlopen error:\n url '%(url)s' - %(val)s"),
|
||||
url=self.ebics_config_id.ebics_url,
|
||||
val=str(value),
|
||||
) from err
|
||||
except EbicsFunctionalError as err:
|
||||
e = exc_info()
|
||||
error = _("EBICS Functional Error:")
|
||||
error += "\n"
|
||||
error += "{} (code: {})".format(e[1].message, e[1].code)
|
||||
raise UserError(error)
|
||||
except EbicsTechnicalError:
|
||||
raise UserError(error) from err
|
||||
except EbicsTechnicalError as err:
|
||||
e = exc_info()
|
||||
error = _("EBICS Technical Error:")
|
||||
error += "\n"
|
||||
error += "{} (code: {})".format(e[1].message, e[1].code)
|
||||
raise UserError(error)
|
||||
raise UserError(error) from err
|
||||
|
||||
# Send the public authentication and encryption keys to the bank.
|
||||
if ebics_version == "H003":
|
||||
@@ -411,25 +410,25 @@ class EbicsUserID(models.Model):
|
||||
userid=self.name,
|
||||
)
|
||||
client = EbicsClient(bank, user, version=self.ebics_config_id.ebics_version)
|
||||
except Exception:
|
||||
except Exception as err:
|
||||
exctype, value = exc_info()[:2]
|
||||
error = _("EBICS Initialisation Error:")
|
||||
error += "\n" + str(exctype) + "\n" + str(value)
|
||||
raise UserError(error)
|
||||
raise UserError(error) from err
|
||||
|
||||
try:
|
||||
public_bank_keys = client.HPB()
|
||||
except EbicsFunctionalError:
|
||||
except EbicsFunctionalError as err:
|
||||
e = exc_info()
|
||||
error = _("EBICS Functional Error:")
|
||||
error += "\n"
|
||||
error += "{} (code: {})".format(e[1].message, e[1].code)
|
||||
raise UserError(error)
|
||||
except Exception:
|
||||
raise UserError(error) from err
|
||||
except Exception as err:
|
||||
exctype, value = exc_info()[:2]
|
||||
error = _("EBICS Initialisation Error:")
|
||||
error += "\n" + str(exctype) + "\n" + str(value)
|
||||
raise UserError(error)
|
||||
raise UserError(error) from err
|
||||
|
||||
public_bank_keys = public_bank_keys.encode()
|
||||
tmp_dir = os.path.normpath(self.ebics_config_id.ebics_files + "/tmp")
|
||||
|
Reference in New Issue
Block a user