Merge branch '16-fix-key-renewal' into '16.0'

[FIX]allow to enter passphrase during key renewal for userid with non-stored passphrase

See merge request Noviat/Noviat_Generic/accounting-ebics!9
This commit is contained in:
Luc De Meyer 2023-09-17 10:14:30 +00:00
commit 77d72f660a
3 changed files with 32 additions and 3 deletions

View File

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

View File

@ -109,6 +109,12 @@ class EbicsUserID(models.Model):
"passphrase for every EBICS transaction, hence do not uncheck this "
"option on a userid for automated EBICS downloads.",
)
ebics_passphrase_required = fields.Boolean(
compute="_compute_ebics_passphrase_view_modifiers"
)
ebics_passphrase_invisible = fields.Boolean(
compute="_compute_ebics_passphrase_view_modifiers"
)
ebics_ini_letter = fields.Binary(
string="EBICS INI Letter",
readonly=True,
@ -208,6 +214,19 @@ class EbicsUserID(models.Model):
rec.ebics_keys_fn
)
@api.depends("state", "ebics_passphrase")
def _compute_ebics_passphrase_view_modifiers(self):
for rec in self:
if rec.state == "draft":
rec.ebics_passphrase_required = True
rec.ebics_passphrase_invisible = False
elif rec.state == "get_bank_keys":
rec.ebics_passphrase_required = not rec.ebics_passphrase
rec.ebics_passphrase_invisible = rec.ebics_passphrase
else:
rec.ebics_passphrase_required = False
rec.ebics_passphrase_invisible = True
@api.constrains("ebics_key_x509")
def _check_ebics_key_x509(self):
for cfg in self:
@ -247,6 +266,14 @@ class EbicsUserID(models.Model):
return self.write({"state": "active_keys"})
def set_to_get_bank_keys(self):
self.ensure_one()
if self.ebics_config_id.state != "draft":
raise UserError(
_(
"Set the EBICS Configuation record to 'Draft' "
"before starting the Key Renewal process."
)
)
return self.write({"state": "get_bank_keys"})
def ebics_init_1(self): # noqa: C901

View File

@ -57,7 +57,7 @@
string="Change Passphrase"
type="object"
class="oe_highlight"
attrs="{'invisible': [('ebics_keys_found', '=', False)]}"
attrs="{'invisible': ['|', ('ebics_keys_found', '=', False), ('state', '!=', 'active_keys')]}"
/>
<button
name="set_to_draft"
@ -86,12 +86,14 @@
<field name="ebics_keys_found" invisible="1" />
<field name="ebics_keys_fn" invisible="1" />
<field name="ebics_version" invisible="1" />
<field name="ebics_passphrase_required" invisible="1" />
<field name="ebics_passphrase_invisible" invisible="1" />
<group name="main-left">
<field name="name" />
<field
name="ebics_passphrase"
password="True"
attrs="{'required': [('ebics_passphrase_store', '=', True)], 'invisible': [('state', '!=', 'draft')]}"
attrs="{'required': [('ebics_passphrase_required', '=', True)], 'invisible': [('ebics_passphrase_invisible', '=', True)]}"
/>
<field name="ebics_passphrase_store" />
<field name="transaction_rights" />