mirror of
https://github.com/brain-tec/account_ebics.git
synced 2024-11-26 06:02:03 +00:00
[14.0][MIG]account_ebics
This commit is contained in:
parent
da95620aa9
commit
b9a9aae709
@ -59,7 +59,7 @@ We also recommend to consider the installation of the following modules:
|
||||
|
||||
|
|
||||
|
||||
- account_bank_statement_import_camt_oca
|
||||
- account_statement_import_camt
|
||||
|
||||
Required to handle camt.052 and camt.054 files.
|
||||
|
||||
@ -67,13 +67,25 @@ We also recommend to consider the installation of the following modules:
|
||||
|
||||
|
|
||||
|
||||
- account_bank_statement_import_helper
|
||||
- account_statement_import_helper
|
||||
|
||||
Required if you are processing bank statements with local bank account numbers (e.g. french CFONB files).
|
||||
Required if you are processing bank statements with local bank account numbers (e.g. french CFONB files)
|
||||
and using import parsers based upon the OCA account_statement_import module.
|
||||
|
||||
The import helper will match the local bank account number with the IBAN number specified on the Odoo Financial journal.
|
||||
|
||||
Cf. https://github.com/noviat-apps
|
||||
Cf. https://github.com/Noviat/noviat-apps
|
||||
|
||||
|
|
||||
|
||||
- account_bank_statement_import_helper
|
||||
|
||||
Required if you are processing bank statements with local bank account numbers
|
||||
and using import parsers based upon the Odoo Enterprise account_bank_statement_import module.
|
||||
|
||||
The import helper will match the local bank account number with the IBAN number specified on the Odoo Financial journal.
|
||||
|
||||
Cf. https://github.com/Noviat/noviat-apps
|
||||
|
||||
|
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright 2009-2020 Noviat.
|
||||
# Copyright 2009-2021 Noviat.
|
||||
# License LGPL-3 or later (http://www.gnu.org/licenses/lpgl).
|
||||
|
||||
import base64
|
||||
@ -138,16 +138,19 @@ class EbicsFile(models.Model):
|
||||
}
|
||||
return res
|
||||
|
||||
def _check_import_module(self, module):
|
||||
mod = self.env['ir.module.module'].search(
|
||||
def _check_import_module(self, module, raise_if_not_found=True):
|
||||
mod = self.env['ir.module.module'].sudo().search(
|
||||
[('name', '=like', module),
|
||||
('state', '=', 'installed')])
|
||||
if not mod:
|
||||
raise UserError(_(
|
||||
"The module to process the '%s' format is not installed "
|
||||
"on your system. "
|
||||
"\nPlease install module '%s'")
|
||||
% (self.format_id.name, module))
|
||||
if raise_if_not_found:
|
||||
raise UserError(_(
|
||||
"The module to process the '%s' format is not installed "
|
||||
"on your system. "
|
||||
"\nPlease install module '%s'")
|
||||
% (self.format_id.name, module))
|
||||
return False
|
||||
return True
|
||||
|
||||
def _process_result_action(self, res):
|
||||
notifications = []
|
||||
@ -287,7 +290,7 @@ class EbicsFile(models.Model):
|
||||
|
||||
@staticmethod
|
||||
def _process_camt052(self):
|
||||
import_module = 'account_bank_statement_import_camt_oca'
|
||||
import_module = 'account_statement_import_camt'
|
||||
self._check_import_module(import_module)
|
||||
return self._process_camt053(self)
|
||||
|
||||
@ -301,7 +304,7 @@ class EbicsFile(models.Model):
|
||||
|
||||
@staticmethod
|
||||
def _process_camt054(self):
|
||||
import_module = 'account_bank_statement_import_camt_oca'
|
||||
import_module = 'account_statement_import_camt'
|
||||
self._check_import_module(import_module)
|
||||
return self._process_camt053(self)
|
||||
|
||||
@ -315,10 +318,67 @@ class EbicsFile(models.Model):
|
||||
|
||||
@staticmethod
|
||||
def _process_camt053(self):
|
||||
import_module = 'account_bank_statement_import_camt%'
|
||||
self._check_import_module(import_module)
|
||||
wiz_model = 'account.bank.statement.import'
|
||||
modules = [
|
||||
('oca', 'account_statement_import_camt'),
|
||||
('oe', 'account_bank_statement_import_camt'),
|
||||
]
|
||||
found = False
|
||||
for src, mod in modules:
|
||||
if self._check_import_module(mod, raise_if_not_found=False):
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
raise UserError(_(
|
||||
"The module to process the '%s' format is not installed "
|
||||
"on your system. "
|
||||
"\nPlease install one of the following modules: \n%s."
|
||||
) % (self.format_id.name, ', '.join([x[1] for x in modules]))
|
||||
)
|
||||
if src == 'oca':
|
||||
self._process_camt053_oca()
|
||||
else:
|
||||
self._process_camt053_oe()
|
||||
|
||||
def _process_camt053_oca(self):
|
||||
wiz_model = 'account.statement.import'
|
||||
wiz_vals = {
|
||||
'statement_filename': self.name,
|
||||
'statement_file': self.data,
|
||||
}
|
||||
result = {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'bank_statement_reconciliation_view',
|
||||
'context': {'statement_line_ids': [],
|
||||
'company_ids': self.env.user.company_ids.ids,
|
||||
'notifications': []},
|
||||
}
|
||||
wiz_ctx = dict(self.env.context, active_model='ebics.file')
|
||||
wiz = self.env[wiz_model].with_context(wiz_ctx).create(wiz_vals)
|
||||
res = wiz.import_file_button()
|
||||
ctx = res.get('context')
|
||||
import pdb; pdb.set_trace()
|
||||
if (res.get('res_model')
|
||||
== 'account.bank.statement.import.journal.creation'):
|
||||
message = _(
|
||||
"Error detected while importing statement %s.\n"
|
||||
) % self.name
|
||||
message += _("No financial journal found.")
|
||||
details = _(
|
||||
'Bank account number: %s'
|
||||
) % ctx.get('default_bank_acc_number')
|
||||
result['context']['notifications'].extend([{
|
||||
'type': 'warning',
|
||||
'message': message,
|
||||
'details': details,
|
||||
}])
|
||||
result['context']['statement_line_ids'].extend(
|
||||
ctx['statement_line_ids'])
|
||||
result['context']['notifications'].extend(
|
||||
ctx['notifications'])
|
||||
return self._process_result_action(result)
|
||||
|
||||
def _process_camt053_oe(self):
|
||||
wiz_model = 'account.bank.statement.import'
|
||||
wiz_vals = {
|
||||
'attachment_ids': [(0, 0, {'name': self.name,
|
||||
'datas': self.data,
|
||||
|
@ -298,7 +298,7 @@ class EbicsXfer(models.TransientModel):
|
||||
suffix = self.format_id.suffix
|
||||
fn = self.upload_fname
|
||||
if not fn.endswith(suffix):
|
||||
fn = '.'.join[fn, suffix]
|
||||
fn = '.'.join([fn, suffix])
|
||||
ef_vals = {
|
||||
'name': self.upload_fname,
|
||||
'data': self.upload_data,
|
||||
|
Loading…
Reference in New Issue
Block a user