mirror of
https://github.com/brain-tec/account_ebics.git
synced 2025-08-14 14:45:36 +00:00
add support for ebics 3.0
This commit is contained in:
@@ -51,7 +51,11 @@ class EbicsConfig(models.Model):
|
||||
help="Contact your bank to get the EBICS URL.",
|
||||
)
|
||||
ebics_version = fields.Selection(
|
||||
selection=[("H003", "H003 (2.4)"), ("H004", "H004 (2.5)")],
|
||||
selection=[
|
||||
("H003", "H003 (2.4)"),
|
||||
("H004", "H004 (2.5)"),
|
||||
("H005", "H005 (3.0)"),
|
||||
],
|
||||
string="EBICS protocol version",
|
||||
readonly=True,
|
||||
states={"draft": [("readonly", False)]},
|
||||
|
@@ -9,9 +9,17 @@ class EbicsFileFormat(models.Model):
|
||||
_description = "EBICS File Formats"
|
||||
_order = "type,name,order_type"
|
||||
|
||||
ebics_version = fields.Selection(
|
||||
selection=[
|
||||
("2", "2"),
|
||||
("3", "3"),
|
||||
],
|
||||
string="EBICS protocol version",
|
||||
required=True,
|
||||
default="2",
|
||||
)
|
||||
name = fields.Char(
|
||||
string="Request Type",
|
||||
required=True,
|
||||
help="E.g. camt.xxx.cfonb120.stm, pain.001.001.03.sct.\n"
|
||||
"Specify camt.052, camt.053, camt.054 for camt "
|
||||
"Order Types such as C53, Z53, C54, Z54.\n"
|
||||
@@ -23,7 +31,8 @@ class EbicsFileFormat(models.Model):
|
||||
)
|
||||
order_type = fields.Char(
|
||||
required=True,
|
||||
help="E.g. C53 (check your EBICS contract).\n"
|
||||
help="EBICS 3.0: BTD (download) or BTU (upload).\n"
|
||||
"EBICS 2.0: E.g. C53 (check your EBICS contract). "
|
||||
"For most banks in France you should use the "
|
||||
"format neutral Order Types 'FUL' for upload "
|
||||
"and 'FDL' for download.",
|
||||
@@ -48,7 +57,48 @@ class EbicsFileFormat(models.Model):
|
||||
description = fields.Char()
|
||||
suffix = fields.Char(
|
||||
required=True,
|
||||
help="Specify the filename suffix for this File Format." "\nE.g. c53.xml",
|
||||
help="Specify the filename suffix for this File Format.\nE.g. c53.xml",
|
||||
)
|
||||
# EBICS 3.0 BTF
|
||||
btf_service = fields.Char(
|
||||
string="BTF Service",
|
||||
help="BTF Service Name)\n"
|
||||
"The service code name consisting of 3 alphanumeric characters "
|
||||
"[A-Z0-9] (e.g. SCT, SDD, STM, EOP)",
|
||||
)
|
||||
btf_message = fields.Char(
|
||||
string="BTF Message Name",
|
||||
help="BTF Message Name\n"
|
||||
"The message name consisting of up to 10 alphanumeric characters "
|
||||
"[a-z0-9.] (eg. pain.001, pain.008, camt.053)",
|
||||
)
|
||||
btf_scope = fields.Char(
|
||||
string="BTF Scope",
|
||||
help="Scope of service.\n"
|
||||
"Either an ISO-3166 ALPHA 2 country code or an issuer code "
|
||||
"of 3 alphanumeric characters [A-Z0-9].",
|
||||
)
|
||||
btf_option = fields.Char(
|
||||
string="BTF Option",
|
||||
help="The service option code consisting of 3-10 alphanumeric "
|
||||
"characters [A-Z0-9] (eg. COR, B2B)",
|
||||
)
|
||||
btf_container = fields.Char(
|
||||
string="BTF Container",
|
||||
help="Type of container consisting of 3 characters [A-Z] (eg. XML, ZIP).",
|
||||
)
|
||||
btf_version = fields.Char(
|
||||
string="BTF Version",
|
||||
help="Message version consisting of 2 numeric characters [0-9] (eg. 03).",
|
||||
)
|
||||
btf_variant = fields.Char(
|
||||
string="BTF Variant",
|
||||
help="Message variant consisting of 3 numeric characters [0-9] (eg. 001).",
|
||||
)
|
||||
btf_format = fields.Char(
|
||||
string="BTF Format",
|
||||
help="Message format consisting of 1-4 alphanumeric characters [A-Z0-9] "
|
||||
"(eg. XML, JSON, PDF).",
|
||||
)
|
||||
|
||||
@api.model
|
||||
@@ -60,3 +110,10 @@ class EbicsFileFormat(models.Model):
|
||||
def _onchange_type(self):
|
||||
if self.type == "up":
|
||||
self.download_process_method = False
|
||||
|
||||
def name_get(self):
|
||||
res = []
|
||||
for rec in self:
|
||||
name = rec.ebics_version == "2" and rec.name or rec.btf_message
|
||||
res.append((rec.id, name))
|
||||
return res
|
||||
|
@@ -14,8 +14,8 @@ from odoo.exceptions import UserError
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
# logging.basicConfig(
|
||||
# level=logging.DEBUG,
|
||||
# format='[%(asctime)s] %(levelname)s - %(name)s: %(message)s')
|
||||
# level=logging.DEBUG,
|
||||
# format='[%(asctime)s] %(levelname)s - %(name)s: %(message)s')
|
||||
|
||||
try:
|
||||
import fintech
|
||||
@@ -173,7 +173,9 @@ class EbicsUserID(models.Model):
|
||||
for rec in self:
|
||||
keys_dir = rec.ebics_config_id.ebics_keys
|
||||
rec.ebics_keys_fn = (
|
||||
rec.name and keys_dir and (keys_dir + "/" + rec.name + "_keys")
|
||||
rec.name
|
||||
and keys_dir
|
||||
and (keys_dir + "/" + rec.name.replace(" ", "_") + "_keys")
|
||||
)
|
||||
|
||||
@api.depends("ebics_keys_fn")
|
||||
@@ -254,7 +256,7 @@ class EbicsUserID(models.Model):
|
||||
# enable import of all type of certicates: A00x, X002, E002
|
||||
if self.swift_3skey:
|
||||
kwargs = {
|
||||
self.ebics_config_id.ebics_key_version: base64.decodestring(
|
||||
self.ebics_config_id.ebics_key_version: base64.decodebytes(
|
||||
self.swift_3skey_certificate
|
||||
),
|
||||
}
|
||||
@@ -300,7 +302,7 @@ class EbicsUserID(models.Model):
|
||||
)
|
||||
try:
|
||||
supported_versions = client.HEV()
|
||||
if ebics_version not in supported_versions:
|
||||
if supported_versions and ebics_version not in supported_versions:
|
||||
err_msg = _("EBICS version mismatch.") + "\n"
|
||||
err_msg += _("Versions supported by your bank:")
|
||||
for k in supported_versions:
|
||||
@@ -321,9 +323,11 @@ class EbicsUserID(models.Model):
|
||||
tb,
|
||||
)
|
||||
raise UserError(
|
||||
_("urlopen error:\n url '%(url)s' - %(val)s"),
|
||||
url=self.ebics_config_id.ebics_url,
|
||||
val=str(value),
|
||||
_(
|
||||
"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()
|
||||
@@ -441,7 +445,7 @@ class EbicsUserID(models.Model):
|
||||
)
|
||||
self.write(
|
||||
{
|
||||
"ebics_public_bank_keys": base64.encodestring(public_bank_keys),
|
||||
"ebics_public_bank_keys": base64.encodebytes(public_bank_keys),
|
||||
"ebics_public_bank_keys_fn": fn,
|
||||
"state": "to_verify",
|
||||
}
|
||||
|
Reference in New Issue
Block a user