mirror of
https://github.com/brain-tec/account_ebics.git
synced 2024-11-23 20:52:04 +00:00
init cycle - usability improvements
This commit is contained in:
parent
4ac89db5db
commit
629b1ffb1d
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': 'EBICS banking protocol',
|
'name': 'EBICS banking protocol',
|
||||||
'version': '11.0.1.6.0',
|
'version': '11.0.1.7.0',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'author': 'Noviat',
|
'author': 'Noviat',
|
||||||
'category': 'Accounting & Finance',
|
'category': 'Accounting & Finance',
|
||||||
|
@ -223,11 +223,11 @@ class EbicsConfig(models.Model):
|
|||||||
'mykeys'])
|
'mykeys'])
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
@api.depends('ebics_keys')
|
||||||
def _compute_ebics_keys_found(self):
|
def _compute_ebics_keys_found(self):
|
||||||
for cfg in self:
|
for cfg in self:
|
||||||
if cfg.ebics_keys:
|
cfg.ebics_keys_found = (
|
||||||
dirname = os.path.dirname(self.ebics_keys)
|
cfg.ebics_keys and os.path.isfile(cfg.ebics_keys))
|
||||||
self.ebics_keys_found = os.path.exists(dirname)
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.constrains('order_number')
|
@api.constrains('order_number')
|
||||||
@ -279,10 +279,14 @@ class EbicsConfig(models.Model):
|
|||||||
raise UserError(
|
raise UserError(
|
||||||
_("Set state to 'draft' before Bank Key (re)initialisation."))
|
_("Set state to 'draft' before Bank Key (re)initialisation."))
|
||||||
|
|
||||||
|
if not self.ebics_passphrase:
|
||||||
|
raise UserError(
|
||||||
|
_("Set a passphrase."))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
keyring = EbicsKeyRing(
|
keyring = EbicsKeyRing(
|
||||||
keys=self.ebics_keys,
|
keys=self.ebics_keys,
|
||||||
passphrase=self.ebics_passphrase or None)
|
passphrase=self.ebics_passphrase)
|
||||||
bank = EbicsBank(
|
bank = EbicsBank(
|
||||||
keyring=keyring, hostid=self.ebics_host, url=self.ebics_url)
|
keyring=keyring, hostid=self.ebics_host, url=self.ebics_url)
|
||||||
user = EbicsUser(
|
user = EbicsUser(
|
||||||
@ -296,9 +300,15 @@ class EbicsConfig(models.Model):
|
|||||||
|
|
||||||
self._check_ebics_keys()
|
self._check_ebics_keys()
|
||||||
if not os.path.isfile(self.ebics_keys):
|
if not os.path.isfile(self.ebics_keys):
|
||||||
user.create_keys(
|
try:
|
||||||
keyversion=self.ebics_key_version,
|
user.create_keys(
|
||||||
bitlength=self.ebics_key_bitlength)
|
keyversion=self.ebics_key_version,
|
||||||
|
bitlength=self.ebics_key_bitlength)
|
||||||
|
except Exception:
|
||||||
|
exctype, value = exc_info()[:2]
|
||||||
|
error = _("EBICS Initialisation Error:")
|
||||||
|
error += '\n' + str(exctype) + '\n' + str(value)
|
||||||
|
raise UserError(error)
|
||||||
|
|
||||||
if self.ebics_key_x509:
|
if self.ebics_key_x509:
|
||||||
dn_attrs = {
|
dn_attrs = {
|
||||||
@ -351,10 +361,13 @@ class EbicsConfig(models.Model):
|
|||||||
self._update_order_number(OrderID)
|
self._update_order_number(OrderID)
|
||||||
|
|
||||||
# Create an INI-letter which must be printed and sent to the bank.
|
# Create an INI-letter which must be printed and sent to the bank.
|
||||||
lang = self.env.user.lang[:2]
|
|
||||||
cc = self.bank_id.bank_id.country.code
|
cc = self.bank_id.bank_id.country.code
|
||||||
if cc in ['FR', 'DE']:
|
if cc in ['FR', 'DE']:
|
||||||
lang = cc
|
lang = cc
|
||||||
|
else:
|
||||||
|
lang = self.env.user.lang or \
|
||||||
|
self.env['res.lang'].search([])[0].code
|
||||||
|
lang = lang[:2]
|
||||||
tmp_dir = os.path.normpath(self.ebics_files + '/tmp')
|
tmp_dir = os.path.normpath(self.ebics_files + '/tmp')
|
||||||
if not os.path.isdir(tmp_dir):
|
if not os.path.isdir(tmp_dir):
|
||||||
os.makedirs(tmp_dir, mode=0o700)
|
os.makedirs(tmp_dir, mode=0o700)
|
||||||
@ -488,6 +501,11 @@ class EbicsConfig(models.Model):
|
|||||||
"EBICS Keys Directory '%s' is not available."
|
"EBICS Keys Directory '%s' is not available."
|
||||||
"\nPlease contact your system administrator.")
|
"\nPlease contact your system administrator.")
|
||||||
% dirname)
|
% dirname)
|
||||||
|
if os.path.isdir(self.ebics_keys):
|
||||||
|
raise UserError(_(
|
||||||
|
"Configuration Error.\n"
|
||||||
|
"The 'EBICS Keys' parameter should be a full path "
|
||||||
|
"(directory + filename) not a directory name."))
|
||||||
|
|
||||||
def _check_ebics_files(self):
|
def _check_ebics_files(self):
|
||||||
dirname = self.ebics_files or ''
|
dirname = self.ebics_files or ''
|
||||||
|
@ -71,7 +71,8 @@
|
|||||||
<group col="4" name="ebics_key">
|
<group col="4" name="ebics_key">
|
||||||
<field name="ebics_keys"/>
|
<field name="ebics_keys"/>
|
||||||
<field name="ebics_keys_found" invisible="1"/>
|
<field name="ebics_keys_found" invisible="1"/>
|
||||||
<field name="ebics_passphrase" password="True" attrs="{'invisible': [('ebics_keys_found', '!=', False)]}"/>
|
<field name="ebics_passphrase" password="True"
|
||||||
|
attrs="{'required': [('state', '=', 'draft')], 'invisible': [('ebics_keys_found', '=', True)]}"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="ebics_key_version"/>
|
<field name="ebics_key_version"/>
|
||||||
<field name="ebics_key_bitlength"/>
|
<field name="ebics_key_bitlength"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user