[14.0]black, isort, prettier

This commit is contained in:
Luc De Meyer
2022-05-10 21:40:54 +02:00
parent ebaa6fd83a
commit 8f19f4ca4b
21 changed files with 1331 additions and 983 deletions

View File

@@ -11,65 +11,58 @@ _logger = logging.getLogger(__name__)
try:
import fintech
from fintech.ebics import EbicsKeyRing
fintech.cryptolib = 'cryptography'
fintech.cryptolib = "cryptography"
except ImportError:
_logger.warning('Failed to import fintech')
_logger.warning("Failed to import fintech")
class EbicsChangePassphrase(models.TransientModel):
_name = 'ebics.change.passphrase'
_description = 'Change EBICS keys passphrase'
_name = "ebics.change.passphrase"
_description = "Change EBICS keys passphrase"
ebics_userid_id = fields.Many2one(
comodel_name='ebics.userid',
string='EBICS UserID',
readonly=True)
old_pass = fields.Char(
string='Old Passphrase',
required=True)
new_pass = fields.Char(
string='New Passphrase',
required=True)
new_pass_check = fields.Char(
string='New Passphrase (verification)',
required=True)
note = fields.Text(string='Notes', readonly=True)
comodel_name="ebics.userid", string="EBICS UserID", readonly=True
)
old_pass = fields.Char(string="Old Passphrase", required=True)
new_pass = fields.Char(string="New Passphrase", required=True)
new_pass_check = fields.Char(string="New Passphrase (verification)", required=True)
note = fields.Text(string="Notes", readonly=True)
def change_passphrase(self):
self.ensure_one()
if self.old_pass != self.ebics_userid_id.ebics_passphrase:
raise UserError(_(
"Incorrect old passphrase."))
raise UserError(_("Incorrect old passphrase."))
if self.new_pass != self.new_pass_check:
raise UserError(_(
"New passphrase verification error."))
raise UserError(_("New passphrase verification error."))
if self.new_pass == self.ebics_userid_id.ebics_passphrase:
raise UserError(_(
"New passphrase equal to old passphrase."))
raise UserError(_("New passphrase equal to old passphrase."))
try:
keyring = EbicsKeyRing(
keys=self.ebics_userid_id.ebics_keys_fn,
passphrase=self.ebics_userid_id.ebics_passphrase)
passphrase=self.ebics_userid_id.ebics_passphrase,
)
keyring.change_passphrase(self.new_pass)
except ValueError as e:
raise UserError(str(e))
self.ebics_userid.ebics_passphrase = self.new_pass
self.note = "The EBICS Passphrase has been changed."
module = __name__.split('addons.')[1].split('.')[0]
module = __name__.split("addons.")[1].split(".")[0]
result_view = self.env.ref(
'%s.ebics_change_passphrase_view_form_result' % module)
"%s.ebics_change_passphrase_view_form_result" % module
)
return {
'name': _('EBICS Keys Change Passphrase'),
'res_id': self.id,
'view_type': 'form',
'view_mode': 'form',
'res_model': 'ebics.change.passphrase',
'view_id': result_view.id,
'target': 'new',
'type': 'ir.actions.act_window',
"name": _("EBICS Keys Change Passphrase"),
"res_id": self.id,
"view_type": "form",
"view_mode": "form",
"res_model": "ebics.change.passphrase",
"view_id": result_view.id,
"target": "new",
"type": "ir.actions.act_window",
}
def button_close(self):
self.ensure_one()
return {'type': 'ir.actions.act_window_close'}
return {"type": "ir.actions.act_window_close"}

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="ebics_change_passphrase_view_form" model="ir.ui.view">
@@ -8,14 +8,19 @@
<field name="arch" type="xml">
<form string="EBICS Keys Change Passphrase">
<group>
<field name="old_pass" password="True"/>
<field name="new_pass" password="True"/>
<field name="new_pass_check" password="True"/>
<field name="old_pass" password="True" />
<field name="new_pass" password="True" />
<field name="new_pass_check" password="True" />
</group>
<footer>
<button name="change_passphrase" string="Change Passphrase" type="object" class="oe_highlight"/>
<button
name="change_passphrase"
string="Change Passphrase"
type="object"
class="oe_highlight"
/>
or
<button string="Cancel" class="oe_link" special="cancel"/>
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
@@ -28,9 +33,9 @@
<field name="arch" type="xml">
<form string="EBICS Keys Change Passphrase">
<separator colspan="4" string="Results :" />
<field name="note" colspan="4" nolabel="1" width="850" height="400"/>
<field name="note" colspan="4" nolabel="1" width="850" height="400" />
<footer>
<button name="button_close" type="object" string="Close"/>
<button name="button_close" type="object" string="Close" />
</footer>
</form>
</field>

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="ebics_xfer_view_form_download" model="ir.ui.view">
@@ -8,23 +8,36 @@
<field name="arch" type="xml">
<form string="EBICS File Download">
<group>
<separator string="Select your bank :" colspan="2"/>
<field name="ebics_config_id" required="1" options="{'no_create': True, 'no_open': True}"/>
<field name="ebics_userid_id"
domain="[('ebics_config_id', '=', ebics_config_id)]"
required="1"
options="{'no_create': True, 'no_open': True}"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="format_id"
domain="[('type', '=', 'down'), ('id', 'in', allowed_format_ids)]"/>
<field name="order_type"/>
<field name="allowed_format_ids" invisible="1"/>
<separator string="Select your bank :" colspan="2" />
<field
name="ebics_config_id"
required="1"
options="{'no_create': True, 'no_open': True}"
/>
<field
name="ebics_userid_id"
domain="[('ebics_config_id', '=', ebics_config_id)]"
required="1"
options="{'no_create': True, 'no_open': True}"
/>
<field name="date_from" />
<field name="date_to" />
<field
name="format_id"
domain="[('type', '=', 'down'), ('id', 'in', allowed_format_ids)]"
/>
<field name="order_type" />
<field name="allowed_format_ids" invisible="1" />
</group>
<footer>
<button name="ebics_download" string="Download Files" type="object" class="oe_highlight"/>
<button
name="ebics_download"
string="Download Files"
type="object"
class="oe_highlight"
/>
or
<button string="Cancel" class="oe_link" special="cancel"/>
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
@@ -37,26 +50,43 @@
<field name="arch" type="xml">
<form string="EBICS File Upload">
<group>
<separator string="Select your bank :" colspan="2"/>
<field name="ebics_config_id" required="1" options="{'no_create': True, 'no_open': True}"/>
<field name="ebics_userid_id"
domain="[('ebics_config_id', '=', ebics_config_id)]"
required="1"
options="{'no_create': True, 'no_open': True}"/>
<separator string="Select your file :" colspan="2"/>
<field name="upload_data" filename="upload_fname" required="1"/>
<field name="upload_fname" invisible="1"/>
<field name="upload_fname_dummy"/>
<field name="format_id" required="1"
domain="[('type', '=', 'up'), ('id', 'in', allowed_format_ids)]"/>
<field name="order_type"/>
<field name="test_mode" attrs="{'invisible': [('order_type', '!=', 'FUL')]}"/>
<field name="allowed_format_ids" invisible="1"/>
<separator string="Select your bank :" colspan="2" />
<field
name="ebics_config_id"
required="1"
options="{'no_create': True, 'no_open': True}"
/>
<field
name="ebics_userid_id"
domain="[('ebics_config_id', '=', ebics_config_id)]"
required="1"
options="{'no_create': True, 'no_open': True}"
/>
<separator string="Select your file :" colspan="2" />
<field name="upload_data" filename="upload_fname" required="1" />
<field name="upload_fname" invisible="1" />
<field name="upload_fname_dummy" />
<field
name="format_id"
required="1"
domain="[('type', '=', 'up'), ('id', 'in', allowed_format_ids)]"
/>
<field name="order_type" />
<field
name="test_mode"
attrs="{'invisible': [('order_type', '!=', 'FUL')]}"
/>
<field name="allowed_format_ids" invisible="1" />
</group>
<footer>
<button name="ebics_upload" string="Upload File" type="object" class="oe_highlight"/>
<button
name="ebics_upload"
string="Upload File"
type="object"
class="oe_highlight"
/>
or
<button string="Cancel" class="oe_link" special="cancel"/>
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
@@ -69,11 +99,16 @@
<field name="arch" type="xml">
<form string="EBICS File Transfer">
<separator colspan="4" string="Results :" />
<field name="note" colspan="4" nolabel="1" width="850" height="400"/>
<field name="note" colspan="4" nolabel="1" width="850" height="400" />
<footer>
<button name="view_ebics_file" type="object" string="View EBICS File(s)" class="oe_highlight"
invisible="not context.get('ebics_file_ids')"/>
<button name="button_close" type="object" string="Close"/>
<button
name="view_ebics_file"
type="object"
string="View EBICS File(s)"
class="oe_highlight"
invisible="not context.get('ebics_file_ids')"
/>
<button name="button_close" type="object" string="Close" />
</footer>
</form>
</field>
@@ -86,7 +121,7 @@
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context">{'ebics_download': 1}</field>
<field name="view_id" ref="ebics_xfer_view_form_download"/>
<field name="view_id" ref="ebics_xfer_view_form_download" />
</record>
<record id="ebics_xfer_action_upload" model="ir.actions.act_window">
@@ -96,7 +131,7 @@
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context">{'ebics_upload': 1}</field>
<field name="view_id" ref="ebics_xfer_view_form_upload"/>
<field name="view_id" ref="ebics_xfer_view_form_upload" />
</record>
</odoo>