mirror of
https://github.com/brain-tec/account_ebics.git
synced 2024-11-23 12:42:04 +00:00
[IMP] account_ebics: pre-commit
This commit is contained in:
parent
89be9036d7
commit
e58b277652
@ -12,6 +12,6 @@ rebel_module_groups: []
|
||||
repo_description: 'TODO: add repo description.'
|
||||
repo_name: account_ebics
|
||||
repo_slug: account_ebics
|
||||
repo_website: https://github.com/Noviat/account_ebics
|
||||
repo_website: https://www.noviat.com
|
||||
travis_apt_packages: []
|
||||
travis_apt_sources: []
|
||||
|
@ -33,7 +33,7 @@ repos:
|
||||
# update the NOT INSTALLABLE ADDONS section above
|
||||
- id: oca-update-pre-commit-excluded-addons
|
||||
- id: oca-fix-manifest-website
|
||||
args: ["https://github.com/Noviat/account_ebics"]
|
||||
args: ["https://www.noviat.com"]
|
||||
- repo: https://github.com/myint/autoflake
|
||||
rev: v1.4
|
||||
hooks:
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
{
|
||||
"name": "EBICS banking protocol",
|
||||
"version": "14.0.1.0.5",
|
||||
"version": "15.0.1.0.0",
|
||||
"license": "LGPL-3",
|
||||
"author": "Noviat",
|
||||
"website": "https://github.com/Noviat/account_ebics",
|
||||
"website": "https://www.noviat.com",
|
||||
"category": "Accounting & Finance",
|
||||
"depends": ["account"],
|
||||
"data": [
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<odoo noupdate="1">
|
||||
|
||||
<!-- Download formats -->
|
||||
|
||||
@ -9,9 +8,7 @@
|
||||
<field name="type">down</field>
|
||||
<field name="order_type">C52</field>
|
||||
<field name="download_process_method">camt.052</field>
|
||||
<field
|
||||
name="description"
|
||||
>bank to customer account report in format camt.052</field>
|
||||
<field name="description">bank to customer account report in format camt.052</field>
|
||||
<field name="suffix">c52.xml</field>
|
||||
</record>
|
||||
|
||||
@ -20,9 +17,7 @@
|
||||
<field name="type">down</field>
|
||||
<field name="order_type">Z52</field>
|
||||
<field name="download_process_method">camt.052</field>
|
||||
<field
|
||||
name="description"
|
||||
>bank to customer account report in format camt.052</field>
|
||||
<field name="description">bank to customer account report in format camt.052</field>
|
||||
<field name="suffix">c52.xml</field>
|
||||
</record>
|
||||
|
||||
@ -176,5 +171,4 @@
|
||||
<field name="suffix">xml</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
@ -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")
|
||||
|
@ -5,7 +5,7 @@
|
||||
<field name="name">ebics.config.tree</field>
|
||||
<field name="model">ebics.config</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="EBICS Configuration" decoration-muted="state == 'draft'">
|
||||
<tree decoration-muted="state == 'draft'">
|
||||
<field name="name" />
|
||||
<field name="ebics_host" />
|
||||
<field name="state" />
|
||||
|
@ -5,7 +5,7 @@
|
||||
<field name="name">ebics.file.format.tree</field>
|
||||
<field name="model">ebics.file.format</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="EBICS File Formats">
|
||||
<tree>
|
||||
<field name="type" />
|
||||
<field name="order_type" />
|
||||
<field name="signature_class" />
|
||||
|
@ -38,7 +38,7 @@
|
||||
<field name="name">ebics.file.tree</field>
|
||||
<field name="model">ebics.file</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="EBICS Files" decoration-muted="state=='draft'" create="false">
|
||||
<tree decoration-muted="state=='draft'" create="false">
|
||||
<field name="date" string="Download Date" />
|
||||
<field name="name" />
|
||||
<field name="date_from" />
|
||||
@ -169,7 +169,7 @@
|
||||
<field name="name">ebics.file.tree</field>
|
||||
<field name="model">ebics.file</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="EBICS Files" decoration-muted="state=='draft'" create="false">
|
||||
<tree decoration-muted="state=='draft'" create="false">
|
||||
<field name="date" string="Upload Date" />
|
||||
<field name="name" />
|
||||
<field name="user_id" />
|
||||
|
@ -5,7 +5,7 @@
|
||||
<field name="name">ebics.userid.tree</field>
|
||||
<field name="model">ebics.userid</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="EBICS UserID" decoration-muted="state != 'active_keys'">
|
||||
<tree decoration-muted="state != 'active_keys'">
|
||||
<field name="name" />
|
||||
<field name="signature_class" />
|
||||
<field name="state" />
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright 2009-2020 Noviat.
|
||||
# Copyright 2009-2022 Noviat.
|
||||
# License LGPL-3 or later (http://www.gnu.org/licenses/lpgl).
|
||||
|
||||
import logging
|
||||
@ -43,8 +43,8 @@ class EbicsChangePassphrase(models.TransientModel):
|
||||
passphrase=self.ebics_userid_id.ebics_passphrase,
|
||||
)
|
||||
keyring.change_passphrase(self.new_pass)
|
||||
except ValueError as e:
|
||||
raise UserError(str(e))
|
||||
except ValueError as err:
|
||||
raise UserError(str(err)) from err
|
||||
self.ebics_userid.ebics_passphrase = self.new_pass
|
||||
self.note = "The EBICS Passphrase has been changed."
|
||||
|
||||
|
@ -86,7 +86,6 @@ class EbicsXfer(models.TransientModel):
|
||||
"and 'FDL' for download.",
|
||||
)
|
||||
test_mode = fields.Boolean(
|
||||
string="Test Mode",
|
||||
help="Select this option to test if the syntax of "
|
||||
"the upload file is correct."
|
||||
"\nThis option is only available for "
|
||||
@ -222,8 +221,11 @@ class EbicsXfer(models.TransientModel):
|
||||
e = exc_info()
|
||||
self.note += "\n"
|
||||
self.note += _(
|
||||
"EBICS Functional Error during download of File Format %s (%s):"
|
||||
) % (df.name, df.order_type)
|
||||
"EBICS Functional Error during download of "
|
||||
"File Format %(name)s (%(order_type)s):",
|
||||
name=df.name,
|
||||
order_type=df.order_type,
|
||||
)
|
||||
self.note += "\n"
|
||||
self.note += "{} (code: {})".format(e[1].message, e[1].code)
|
||||
except EbicsTechnicalError:
|
||||
@ -231,8 +233,11 @@ class EbicsXfer(models.TransientModel):
|
||||
e = exc_info()
|
||||
self.note += "\n"
|
||||
self.note += _(
|
||||
"EBICS Technical Error during download of File Format %s (%s):"
|
||||
) % (df.name, df.order_type)
|
||||
"EBICS Technical Error during download of "
|
||||
"File Format %(name)s (%(order_type)s):",
|
||||
name=df.name,
|
||||
order_type=df.order_type,
|
||||
)
|
||||
self.note += "\n"
|
||||
self.note += "{} (code: {})".format(e[1].message, e[1].code)
|
||||
except EbicsVerificationError:
|
||||
@ -240,23 +245,31 @@ class EbicsXfer(models.TransientModel):
|
||||
self.note += "\n"
|
||||
self.note += _(
|
||||
"EBICS Verification Error during download of "
|
||||
"File Format %s (%s):"
|
||||
) % (df.name, df.order_type)
|
||||
"File Format %(name)s (%(order_type)s):",
|
||||
name=df.name,
|
||||
order_type=df.order_type,
|
||||
)
|
||||
self.note += "\n"
|
||||
self.note += _("The EBICS response could not be verified.")
|
||||
except UserError as e:
|
||||
self.note += "\n"
|
||||
self.note += _(
|
||||
"Warning during download of File Format %s (%s):"
|
||||
) % (df.name, df.order_type)
|
||||
"Warning during download of "
|
||||
"File Format %(name)s (%(order_type)s):",
|
||||
name=df.name,
|
||||
order_type=df.order_type,
|
||||
)
|
||||
self.note += "\n"
|
||||
self.note += e.name
|
||||
except Exception:
|
||||
err_cnt += 1
|
||||
self.note += "\n"
|
||||
self.note += _(
|
||||
"Unknown Error during download of File Format %s (%s):"
|
||||
) % (df.name, df.order_type)
|
||||
"Unknown Error during download of "
|
||||
"File Format %(name)s (%(order_type)s):",
|
||||
name=df.name,
|
||||
order_type=df.order_type,
|
||||
)
|
||||
tb = "".join(format_exception(*exc_info()))
|
||||
self.note += "\n%s" % tb
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user