mirror of
https://github.com/brain-tec/account_ebics.git
synced 2025-08-02 16:59:20 +00:00
13 multi bank account support (#15)
* [13.0][IMP]add support for multiple bank accounts and multiple EBICS UserIDs over a single EBICS connection * ebics refactoring fixes * ebics refactoring fixes
This commit is contained in:
18
account_ebics/migrations/13.0.1.1/noupdate_changes.xml
Normal file
18
account_ebics/migrations/13.0.1.1/noupdate_changes.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<odoo>
|
||||
|
||||
<record id="ebics_config_comp_rule" model="ir.rule">
|
||||
<field name="name">EBICS Configuration model company rule</field>
|
||||
<field name="model_id" ref="model_ebics_config"/>
|
||||
<field eval="True" name="global"/>
|
||||
<field name="domain_force">['|', ('company_ids', '=', False), ('company_ids', 'in', user.company_ids.ids)]</field>
|
||||
</record>
|
||||
|
||||
<record id="ebics_file_comp_rule" model="ir.rule">
|
||||
<field name="name">EBICS File model company rule</field>
|
||||
<field name="model_id" ref="model_ebics_file"/>
|
||||
<field eval="True" name="global"/>
|
||||
<field name="domain_force">['|', ('company_ids', '=', False), ('company_ids', 'in', user.company_ids.ids)]</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
73
account_ebics/migrations/13.0.1.1/post-migration.py
Normal file
73
account_ebics/migrations/13.0.1.1/post-migration.py
Normal file
@@ -0,0 +1,73 @@
|
||||
# Copyright 2009-2020 Noviat.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openupgradelib import openupgrade # pylint: disable=W7936
|
||||
import os
|
||||
|
||||
|
||||
@openupgrade.migrate()
|
||||
def migrate(env, version):
|
||||
|
||||
_ebics_config_upgrade(env, version)
|
||||
_noupdate_changes(env, version)
|
||||
|
||||
|
||||
def _ebics_config_upgrade(env, version):
|
||||
env.cr.execute("SELECT * FROM ebics_config")
|
||||
cfg_datas = env.cr.dictfetchall()
|
||||
for cfg_data in cfg_datas:
|
||||
cfg = env['ebics.config'].browse(cfg_data['id'])
|
||||
journal = env['account.journal'].search(
|
||||
[('bank_account_id', '=', cfg_data['bank_id'])])
|
||||
keys_fn_old = cfg_data['ebics_keys']
|
||||
ebics_keys_root = os.path.dirname(keys_fn_old)
|
||||
if os.path.isfile(keys_fn_old):
|
||||
keys_fn = ebics_keys_root + '/' + cfg_data['ebics_user']
|
||||
os.rename(keys_fn_old, keys_fn)
|
||||
state = cfg_data['state'] == 'active' and 'confirm' or 'draft'
|
||||
cfg.write({
|
||||
'company_ids': [(6, 0, [cfg_data['company_id']])],
|
||||
'journal_ids': [(6, 0, [journal.id])],
|
||||
'ebics_keys': ebics_keys_root,
|
||||
'state': state,
|
||||
})
|
||||
|
||||
user_vals = {
|
||||
'ebics_config_id': cfg_data['id'],
|
||||
'name': cfg_data['ebics_user'],
|
||||
}
|
||||
for fld in [
|
||||
'signature_class', 'ebics_passphrase',
|
||||
'ebics_ini_letter_fn', 'ebics_public_bank_keys_fn',
|
||||
'ebics_key_x509', 'ebics_key_x509_dn_cn',
|
||||
'ebics_key_x509_dn_o', 'ebics_key_x509_dn_ou',
|
||||
'ebics_key_x509_dn_c', 'ebics_key_x509_dn_st',
|
||||
'ebics_key_x509_dn_l', 'ebics_key_x509_dn_e',
|
||||
'ebics_file_format_ids', 'state']:
|
||||
if cfg_data.get(fld):
|
||||
if fld == 'ebics_file_format_ids':
|
||||
user_vals[fld] = [(6, 0, cfg_data[fld])]
|
||||
elif fld == 'state' and cfg_data['state'] == 'active':
|
||||
user_vals['state'] = 'active_keys'
|
||||
else:
|
||||
user_vals[fld] = cfg_data[fld]
|
||||
ebics_userid = env['ebics.userid'].create(user_vals)
|
||||
env.cr.execute(
|
||||
"""
|
||||
UPDATE ir_attachment
|
||||
SET res_model = 'ebics.userid', res_id = %s
|
||||
WHERE name in ('ebics_ini_letter', 'ebics_public_bank_keys');
|
||||
"""
|
||||
% ebics_userid.id)
|
||||
|
||||
if len(cfg_datas) == 1:
|
||||
env.cr.execute(
|
||||
"UPDATE ebics_file SET ebics_userid_id = %s" % ebics_userid.id)
|
||||
|
||||
|
||||
def _noupdate_changes(env, version):
|
||||
openupgrade.load_data(
|
||||
env.cr,
|
||||
'account_ebics',
|
||||
'migrations/13.0.1.1/noupdate_changes.xml'
|
||||
)
|
9
account_ebics/migrations/13.0.1.1/pre-migration.py
Normal file
9
account_ebics/migrations/13.0.1.1/pre-migration.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# Copyright 2009-2020 Noviat.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
if not version:
|
||||
return
|
||||
|
||||
cr.execute("DELETE FROM ebics_xfer;")
|
Reference in New Issue
Block a user