[MIG] account_ebics: Migration to 17.0

This commit is contained in:
Luc De Meyer 2024-01-26 22:36:02 +01:00
parent 08482045d8
commit cb5ac3ac23
11 changed files with 81 additions and 151 deletions

View File

@ -3,7 +3,7 @@
{
"name": "EBICS banking protocol",
"version": "16.0.1.9.0",
"version": "17.0.1.0.0",
"license": "LGPL-3",
"author": "Noviat",
"website": "https://www.noviat.com",

View File

@ -1,4 +1,4 @@
# Copyright 2009-2023 Noviat.
# Copyright 2009-2024 Noviat.
# License LGPL-3 or later (http://www.gnu.org/licenses/lgpl).
import logging
@ -22,23 +22,17 @@ class EbicsConfig(models.Model):
_order = "name"
name = fields.Char(
readonly=True,
states={"draft": [("readonly", False)]},
required=True,
)
journal_ids = fields.Many2many(
comodel_name="account.journal",
relation="account_journal_ebics_config_rel",
readonly=True,
states={"draft": [("readonly", False)]},
string="Bank Accounts",
domain="[('type', '=', 'bank')]",
)
ebics_host = fields.Char(
string="EBICS HostID",
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
help="Contact your bank to get the EBICS HostID."
"\nIn France the BIC is usually allocated to the HostID "
"whereas in Germany it tends to be an institute specific string "
@ -47,8 +41,6 @@ class EbicsConfig(models.Model):
ebics_url = fields.Char(
string="EBICS URL",
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
help="Contact your bank to get the EBICS URL.",
)
ebics_version = fields.Selection(
@ -58,16 +50,12 @@ class EbicsConfig(models.Model):
("H005", "H005 (3.0)"),
],
string="EBICS protocol version",
readonly=True,
states={"draft": [("readonly", False)]},
required=True,
default="H004",
)
ebics_partner = fields.Char(
string="EBICS PartnerID",
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
help="Organizational unit (company or individual) "
"that concludes a contract with the bank. "
"\nIn this contract it will be agreed which order types "
@ -81,8 +69,6 @@ class EbicsConfig(models.Model):
comodel_name="ebics.userid",
inverse_name="ebics_config_id",
string="EBICS UserID",
readonly=True,
states={"draft": [("readonly", False)]},
help="Human users or a technical system that is/are "
"assigned to a customer. "
"\nOn the EBICS bank server it is identified "
@ -96,8 +82,6 @@ class EbicsConfig(models.Model):
ebics_keys = fields.Char(
string="EBICS Keys Root",
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
default=lambda self: self._default_ebics_keys(),
help="Root Directory for storing the EBICS Keys.",
)
@ -105,15 +89,11 @@ class EbicsConfig(models.Model):
selection=[("A005", "A005 (RSASSA-PKCS1-v1_5)"), ("A006", "A006 (RSASSA-PSS)")],
string="EBICS key version",
default="A006",
readonly=True,
states={"draft": [("readonly", False)]},
help="The key version of the electronic signature.",
)
ebics_key_bitlength = fields.Integer(
string="EBICS key bitlength",
default=2048,
readonly=True,
states={"draft": [("readonly", False)]},
help="The bit length of the generated keys. "
"\nThe value must be between 1536 and 4096.",
)
@ -122,19 +102,15 @@ class EbicsConfig(models.Model):
column1="config_id",
column2="format_id",
string="EBICS File Format",
readonly=True,
states={"draft": [("readonly", False)]},
)
state = fields.Selection(
[("draft", "Draft"), ("confirm", "Confirmed")],
selection=[("draft", "Draft"), ("confirm", "Confirmed")],
default="draft",
required=True,
readonly=True,
)
order_number = fields.Char(
size=4,
readonly=True,
states={"draft": [("readonly", False)]},
help="Specify the number for the next order."
"\nThis number should match the following pattern : "
"[A-Z]{1}[A-Z0-9]{3}",

View File

@ -1,4 +1,4 @@
# Copyright 2009-2023 Noviat.
# Copyright 2009-2024 Noviat.
# License LGPL-3 or later (http://www.gnu.org/licenses/lgpl).
from odoo import api, fields, models
@ -110,11 +110,10 @@ class EbicsFileFormat(models.Model):
if self.type == "up":
self.download_process_method = False
def name_get(self):
res = []
@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
if rec.description:
name += " - " + rec.description
res.append((rec.id, name))
return res
rec.display_name = name

View File

@ -47,8 +47,6 @@ class EbicsUserID(models.Model):
name = fields.Char(
string="EBICS UserID",
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
help="Human users or a technical system that is/are "
"assigned to a customer. "
"\nOn the EBICS bank server it is identified "
@ -71,14 +69,10 @@ class EbicsUserID(models.Model):
help="Users who are allowed to use this EBICS UserID for "
" bank transactions.",
)
# Currently only a single signature class per user is supported
# Classes A and B are not yet supported.
signature_class = fields.Selection(
selection=[("E", "Single signature"), ("T", "Transport signature")],
required=True,
default="T",
readonly=True,
states={"draft": [("readonly", False)]},
help="Default signature class."
"This default can be overriden for specific "
"EBICS transactions (cf. File Formats).",
@ -152,44 +146,28 @@ class EbicsUserID(models.Model):
# create self-signed X.509 certificates
ebics_key_x509 = fields.Boolean(
string="X509 support",
readonly=True,
states={"draft": [("readonly", False)]},
help="Set this flag in order to work with " "self-signed X.509 certificates",
)
ebics_key_x509_dn_cn = fields.Char(
string="Common Name [CN]",
readonly=True,
states={"draft": [("readonly", False)]},
)
ebics_key_x509_dn_o = fields.Char(
string="Organization Name [O]",
readonly=True,
states={"draft": [("readonly", False)]},
)
ebics_key_x509_dn_ou = fields.Char(
string="Organizational Unit Name [OU]",
readonly=True,
states={"draft": [("readonly", False)]},
)
ebics_key_x509_dn_c = fields.Char(
string="Country Name [C]",
readonly=True,
states={"draft": [("readonly", False)]},
)
ebics_key_x509_dn_st = fields.Char(
string="State Or Province Name [ST]",
readonly=True,
states={"draft": [("readonly", False)]},
)
ebics_key_x509_dn_l = fields.Char(
string="Locality Name [L]",
readonly=True,
states={"draft": [("readonly", False)]},
)
ebics_key_x509_dn_e = fields.Char(
string="Email Address",
readonly=True,
states={"draft": [("readonly", False)]},
)
state = fields.Selection(
[

View File

@ -22,7 +22,7 @@
<header>
<button
name="set_to_draft"
states="confirm"
invisible="state != 'confirm'"
string="Set to Draft"
type="object"
groups="account_ebics.group_ebics_manager"
@ -30,7 +30,7 @@
/>
<button
name="set_to_confirm"
states="draft"
invisible="state != 'draft'"
string="Confirm"
type="object"
class="oe_highlight"
@ -44,38 +44,40 @@
name="web_ribbon"
text="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active"
/>
<group name="main">
<group name="main-left">
<field name="name" colspan="2" />
<field name="ebics_host" />
<field name="ebics_url" />
<field name="ebics_partner" />
<field name="ebics_keys" />
<field name="name" readonly="state != 'draft'" colspan="2" />
<field name="ebics_host" readonly="state != 'draft'" />
<field name="ebics_url" readonly="state != 'draft'" />
<field name="ebics_partner" readonly="state != 'draft'" />
<field name="ebics_keys" readonly="state != 'draft'" />
</group>
<group name="main-right">
<field
name="journal_ids"
readonly="state != 'draft'"
widget="many2many_tags"
options="{'no_create': True}"
/>
<field name="ebics_version" />
<field name="ebics_key_version" />
<field name="ebics_key_bitlength" />
<field name="ebics_version" readonly="state != 'draft'" />
<field name="ebics_key_version" readonly="state != 'draft'" />
<field name="ebics_key_bitlength" readonly="state != 'draft'" />
<field
name="order_number"
attrs="{'invisible': [('ebics_version', '!=', 'H003')]}"
invisible="ebics_version != 'H003'"
readonly="state != 'draft'"
/>
<field name="company_ids" widget="many2many_tags" invisible="1" />
</group>
</group>
<notebook>
<page string="EBICS Users" groups="account_ebics.group_ebics_manager">
<field name="ebics_userid_ids" />
<field name="ebics_userid_ids" readonly="state != 'draft'" />
</page>
<page string="File Formats" groups="account_ebics.group_ebics_manager">
<field name="ebics_file_format_ids" />
<field name="ebics_file_format_ids" readonly="state != 'draft'" />
</page>
</notebook>
</form>

View File

@ -28,7 +28,7 @@
<field name="suffix" />
<field
name="download_process_method"
attrs="{'invisible': [('type', '=', 'up')]}"
invisible="type == 'up'"
force_save="1"
/>
<field name="signature_class" />
@ -37,40 +37,25 @@
<field name="order_type" />
<field
name="name"
attrs="{'required': [('ebics_version', '=', '2')], 'invisible': [('ebics_version', '=', '3')]}"
required="ebics_version == '2'"
invisible="ebics_version == '3'"
/>
<field
name="btf_service"
attrs="{'required': [('ebics_version', '=', '3')], 'invisible': [('ebics_version', '=', '2')]}"
required="ebics_version == '3'"
invisible="ebics_version == '2'"
/>
<field
name="btf_message"
attrs="{'required': [('ebics_version', '=', '3')], 'invisible': [('ebics_version', '=', '2')]}"
/>
<field
name="btf_scope"
attrs="{'invisible': [('ebics_version', '=', '2')]}"
/>
<field
name="btf_option"
attrs="{'invisible': [('ebics_version', '=', '2')]}"
/>
<field
name="btf_container"
attrs="{'invisible': [('ebics_version', '=', '2')]}"
/>
<field
name="btf_version"
attrs="{'invisible': [('ebics_version', '=', '2')]}"
/>
<field
name="btf_variant"
attrs="{'invisible': [('ebics_version', '=', '2')]}"
/>
<field
name="btf_format"
attrs="{'invisible': [('ebics_version', '=', '2')]}"
required="ebics_version == '3'"
invisible="ebics_version == '2'"
/>
<field name="btf_scope" invisible="ebics_version == '2'" />
<field name="btf_option" invisible="ebics_version == '2'" />
<field name="btf_container" invisible="ebics_version == '2'" />
<field name="btf_version" invisible="ebics_version == '2'" />
<field name="btf_variant" invisible="ebics_version == '2'" />
<field name="btf_format" invisible="ebics_version == '2'" />
</group>
</group>
<group name="description">

View File

@ -64,7 +64,7 @@
<header>
<button
name="set_to_draft"
states="done"
invisible="state != 'done'"
string="Set to Draft"
type="object"
groups="account.group_account_manager"
@ -72,7 +72,7 @@
<button
name="process"
class="oe_highlight"
states="draft"
invisible="state != 'draft'"
string="Process"
type="object"
groups="account.group_account_invoice"
@ -80,7 +80,7 @@
/>
<button
name="set_to_done"
states="draft"
invisible="state != 'draft'"
string="Set to Done"
type="object"
groups="account.group_account_manager"
@ -106,10 +106,7 @@
<page string="Additional Information">
<field name="note" nolabel="1" />
</page>
<page
string="Bank Statements"
attrs="{'invisible':[('bank_statement_ids','=',[])]}"
>
<page string="Bank Statements" invisible="not bank_statement_ids">
<field name="bank_statement_ids" nolabel="1" />
</page>
</notebook>
@ -193,14 +190,14 @@
<header>
<button
name="set_to_draft"
states="done"
invisible="state != 'done'"
string="Set to Draft"
type="object"
groups="account.group_account_manager"
/>
<button
name="set_to_done"
states="draft"
invisible="state != 'draft'"
string="Set to Done"
type="object"
groups="account.group_account_manager"

View File

@ -22,7 +22,7 @@
<header>
<button
name="ebics_init_1"
states="draft"
invisible="state != 'draft'"
string="EBICS Initialisation"
type="object"
class="oe_highlight"
@ -30,7 +30,7 @@
/>
<button
name="ebics_init_2"
states="init"
invisible="state != 'init'"
string="Account activated"
type="object"
class="oe_highlight"
@ -38,7 +38,7 @@
/>
<button
name="ebics_init_3"
states="get_bank_keys"
invisible="state != 'get_bank_keys'"
string="Get Bank Keys"
type="object"
class="oe_highlight"
@ -46,7 +46,7 @@
/>
<button
name="ebics_init_4"
states="to_verify"
invisible="state != 'to_verify'"
string="Bank Keys Verified"
type="object"
class="oe_highlight"
@ -57,25 +57,25 @@
string="Change Passphrase"
type="object"
class="oe_highlight"
attrs="{'invisible': ['|', ('ebics_keys_found', '=', False), ('state', '!=', 'active_keys')]}"
invisible="not ebics_keys_found or state != 'active_keys'"
/>
<button
name="set_to_draft"
states="active_keys"
invisible="state != 'active_keys'"
string="Set to Draft"
type="object"
help="Set to Draft in order to reinitialize your bank connection."
/>
<button
name="set_to_get_bank_keys"
states="active_keys"
invisible="state != 'active_keys'"
string="Renew Bank Keys"
type="object"
help="Use this button to update the EBICS certificates of your bank."
/>
<button
name="set_to_active_keys"
states="draft"
invisible="state != 'draft'"
string="Force Active Keys"
type="object"
help="Use this button to bypass the EBICS initialization (e.g. in case you have manually transferred active EBICS keys from another system."
@ -91,28 +91,29 @@
<field name="ebics_passphrase_store_readonly" />
<field name="ebics_sig_passphrase_invisible" invisible="1" />
</group>
<group name="main" attrs="{'readonly': [('state', '!=', 'draft')]}">
<group name="main" readonly="state != 'draft'">
<group name="main-left">
<field name="name" />
<field name="name" readonly="state != 'draft'" />
<field
name="ebics_passphrase"
password="True"
attrs="{'required': [('ebics_passphrase_required', '=', True)], 'invisible': [('ebics_passphrase_invisible', '=', True)]}"
required="ebics_passphrase_required"
invisible="ebics_passphrase_invisible"
/>
<field
name="ebics_passphrase_store"
attrs="{'readonly': [('ebics_passphrase_store_readonly', '=', True)]}"
readonly="ebics_passphrase_store_readonly"
/>
<field
name="ebics_sig_passphrase"
password="True"
attrs="{'invisible': [('ebics_sig_passphrase_invisible', '=', True)]}"
invisible="ebics_sig_passphrase_invisible"
/>
<field name="transaction_rights" />
<field name="active" />
</group>
<group name="main-right">
<field name="signature_class" />
<field name="signature_class" readonly="state != 'draft'" />
<field
name="user_ids"
widget="many2many_tags"
@ -121,51 +122,45 @@
<!-- TODO: restore these fields after implementation of SWIFT SConnect
<field
name="swift_3skey"
attrs="{'invisible': [('signature_class', '=', 'T')]}"
invisible="signature_class == 'T'"
/>
<field name="swift_3skey_certificate_fn" invisible="1" />
<field
name="swift_3skey_certificate"
filename="swift_3skey_certificate_fn"
attrs="{'invisible': [('swift_3skey', '=', False)], 'required': [('swift_3skey', '=', True)]}"
invisible="not swift_3skey"
required="swift_3skey"
/>
-->
<field name="ebics_key_x509" />
<field name="ebics_key_x509" readonly="state != 'draft'" />
</group>
</group>
<group
name="dn"
attrs="{'invisible': [('ebics_key_x509', '=', False)], 'readonly': [('state', '!=', 'draft')]}"
>
<group name="dn" invisible="not ebics_key_x509" readonly="state != 'draft'">
<div colspan="2" col="1">
<strong
>Distinguished Name attributes used to create self-signed X.509 certificates:</strong>
</div>
<group name="dn_l">
<field name="ebics_key_x509_dn_cn" />
<field name="ebics_key_x509_dn_o" />
<field name="ebics_key_x509_dn_l" />
<field name="ebics_key_x509_dn_c" />
<field name="ebics_key_x509_dn_cn" readonly="state != 'draft'" />
<field name="ebics_key_x509_dn_o" readonly="state != 'draft'" />
<field name="ebics_key_x509_dn_l" readonly="state != 'draft'" />
<field name="ebics_key_x509_dn_c" readonly="state != 'draft'" />
</group>
<group name="dn_r">
<field name="ebics_key_x509_dn_e" />
<field name="ebics_key_x509_dn_ou" />
<field name="ebics_key_x509_dn_st" />
<field name="ebics_key_x509_dn_e" readonly="state != 'draft'" />
<field name="ebics_key_x509_dn_ou" readonly="state != 'draft'" />
<field name="ebics_key_x509_dn_st" readonly="state != 'draft'" />
</group>
</group>
<group name="files">
<group
colspan="2"
name="ebics_ini_letter"
attrs="{'invisible': [('ebics_ini_letter', '=', False)]}"
>
<group colspan="2" name="ebics_ini_letter" invisible="not ebics_ini_letter">
<field name="ebics_ini_letter_fn" invisible="1" />
<field name="ebics_ini_letter" filename="ebics_ini_letter_fn" />
</group>
<group
colspan="2"
name="ebics_public_bank_keys"
attrs="{'invisible': [('ebics_public_bank_keys', '=', False)]}"
invisible="not ebics_public_bank_keys"
>
<field name="ebics_public_bank_keys_fn" invisible="1" />
<field name="ebics_public_bank_keys" filename="ebics_public_bank_keys_fn" />

View File

@ -13,10 +13,7 @@
<field name="new_pass" password="True" />
<field name="new_pass_check" password="True" />
</group>
<group
name="sig_pass"
attrs="{'invisible': [('ebics_sig_passphrase_invisible', '=', True)]}"
>
<group name="sig_pass" invisible="ebics_sig_passphrase_invisible">
<field name="old_sig_pass" password="True" />
<field name="new_sig_pass" password="True" />
<field name="new_sig_pass_check" password="True" />

View File

@ -444,7 +444,9 @@ class EbicsXfer(models.TransientModel):
def _payment_order_postprocess(self, ebics_file):
active_model = self.env.context.get("active_model")
if active_model == "account.payment.order":
order = self.env[active_model].browse(self.env.context["active_id"])
order = self.env["account.payment.order"].browse(
self.env.context["active_id"]
)
order.generated2uploaded()
def _setup_client(self):

View File

@ -23,7 +23,8 @@
<field
name="ebics_passphrase"
password="True"
attrs="{'invisible': [('ebics_passphrase_store', '=', True)], 'required': [('ebics_passphrase_store', '=', False)]}"
invisible="ebics_passphrase_store"
required="not ebics_passphrase_store"
/>
<field name="ebics_passphrase_store" invisible="1" />
<field name="date_from" />
@ -76,12 +77,13 @@
<field
name="ebics_passphrase"
password="True"
attrs="{'invisible': [('ebics_passphrase_store', '=', True)], 'required': [('ebics_passphrase_store', '=', False)]}"
invisible="ebics_passphrase_store"
required="not ebics_passphrase_store"
/>
<field
name="ebics_sig_passphrase"
password="True"
attrs="{'invisible': [('ebics_sig_passphrase_invisible', '=', True)]}"
invisible="ebics_sig_passphrase_invisible"
/>
<field name="ebics_passphrase_store" invisible="1" />
<field name="ebics_sig_passphrase_invisible" invisible="1" />
@ -95,10 +97,7 @@
domain="[('type', '=', 'up'), ('id', 'in', allowed_format_ids)]"
/>
<field name="order_type" />
<field
name="test_mode"
attrs="{'invisible': [('order_type', 'not in', ('FUL', 'BTU'))]}"
/>
<field name="test_mode" invisible="order_type not in ('FUL', 'BTU')" />
<field name="allowed_format_ids" invisible="1" />
</group>
<footer>