mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[MIG] account_bank_statement_import_save_file: Migrated to 10.0
This commit is contained in:
committed by
Alexis de Lattre
parent
88010bf8f4
commit
9298b5944b
@@ -1,3 +1,8 @@
|
|||||||
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||||
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
|
:alt: License: AGPL-3
|
||||||
|
|
||||||
|
============================
|
||||||
Save imported statement file
|
Save imported statement file
|
||||||
============================
|
============================
|
||||||
|
|
||||||
@@ -8,28 +13,41 @@ Usage
|
|||||||
|
|
||||||
On a successful import, the generated statement(s) link to an attachment containing the original file.
|
On a successful import, the generated statement(s) link to an attachment containing the original file.
|
||||||
|
|
||||||
|
Bug Tracker
|
||||||
|
===========
|
||||||
|
|
||||||
|
Bugs are tracked on `GitHub Issues
|
||||||
|
<https://github.com/OCA/bank-statement-import/issues>`_. In case of trouble, please
|
||||||
|
check there if your issue has already been reported. If you spotted it first,
|
||||||
|
help us smash it by providing detailed and welcomed feedback.
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
|
||||||
|
Images
|
||||||
|
------
|
||||||
|
|
||||||
|
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||||
|
|
||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* Holger Brunn <hbrunn@therp.nl>
|
* Holger Brunn <hbrunn@therp.nl>
|
||||||
|
* Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
|
||||||
Icon
|
|
||||||
----
|
|
||||||
|
|
||||||
* https://commons.wikimedia.org/wiki/File:Paper_clip_font_awesome.svg
|
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
----------
|
----------
|
||||||
|
|
||||||
.. image:: http://odoo-community.org/logo.png
|
|
||||||
:alt: Odoo Community Association
|
.. image:: https://odoo-community.org/logo.png
|
||||||
:target: http://odoo-community.org
|
:alt: Odoo Community Association
|
||||||
|
:target: https://odoo-community.org
|
||||||
|
|
||||||
This module is maintained by the OCA.
|
This module is maintained by the OCA.
|
||||||
|
|
||||||
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
|
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
|
mission is to support the collaborative development of Odoo features and
|
||||||
|
promote its widespread use.
|
||||||
|
|
||||||
To contribute to this module, please visit http://odoo-community.org.
|
To contribute to this module, please visit https://odoo-community.org.
|
||||||
@@ -1,22 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# © 2015 Therp BV (<http://therp.nl>).
|
||||||
#
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# This module copyright (C) 2015 Therp BV <http://therp.nl>.
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
from . import models
|
from . import models
|
||||||
from .hooks import _post_init_hook
|
from .hooks import _post_init_hook
|
||||||
|
|||||||
@@ -1,25 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# © 2015 Therp BV (<http://therp.nl>).
|
||||||
#
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
# Copyright (C) 2015 Therp BV <http://therp.nl>.
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
{
|
{
|
||||||
'name': 'Save imported bank statements',
|
'name': 'Save imported bank statements',
|
||||||
'version': '8.0.1.0.1',
|
'version': '10.0.1.0.0',
|
||||||
'author': 'Odoo Community Association (OCA), Therp BV',
|
'author': 'Odoo Community Association (OCA), Therp BV',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'category': 'Banking addons',
|
'category': 'Banking addons',
|
||||||
|
|||||||
@@ -1,24 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# © 2015 Therp BV (<http://therp.nl>).
|
||||||
#
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# This module copyright (C) 2015 Therp BV <http://therp.nl>.
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
from openerp import SUPERUSER_ID
|
|
||||||
|
|
||||||
|
|
||||||
def _post_init_hook(cr, pool):
|
def _post_init_hook(cr, pool):
|
||||||
@@ -89,7 +71,6 @@ def _post_init_hook_migrate_account_banking_imported_file(cr, pool):
|
|||||||
(tuple(attachment_ids),)
|
(tuple(attachment_ids),)
|
||||||
)
|
)
|
||||||
for attachment_id, content in cr.fetchall():
|
for attachment_id, content in cr.fetchall():
|
||||||
pool['ir.attachment'].write(
|
pool['ir.attachment'].sudo().write(
|
||||||
cr, SUPERUSER_ID,
|
|
||||||
[attachment_id],
|
[attachment_id],
|
||||||
{'datas': str(content)})
|
{'datas': str(content)})
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ msgstr "Importer Relevé Bancaire"
|
|||||||
#. module: account_bank_statement_import_save_file
|
#. module: account_bank_statement_import_save_file
|
||||||
#: field:account.bank.statement,import_file:0
|
#: field:account.bank.statement,import_file:0
|
||||||
msgid "Import file"
|
msgid "Import file"
|
||||||
msgstr "Importation de fichier"
|
msgstr "Fichier importé"
|
||||||
|
|
||||||
#. module: account_bank_statement_import_save_file
|
#. module: account_bank_statement_import_save_file
|
||||||
#: view:account.bank.statement:account_bank_statement_import_save_file.view_bank_statement_form
|
#: view:account.bank.statement:account_bank_statement_import_save_file.view_bank_statement_form
|
||||||
|
|||||||
@@ -1,22 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# © 2015 Therp BV (<http://therp.nl>).
|
||||||
#
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# This module copyright (C) 2015 Therp BV <http://therp.nl>.
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
from . import account_bank_statement
|
from . import account_bank_statement
|
||||||
from . import account_bank_statement_import
|
from . import account_bank_statement_import
|
||||||
|
|||||||
@@ -1,24 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# © 2015 Therp BV (<http://therp.nl>).
|
||||||
#
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# This module copyright (C) 2015 Therp BV (<http://therp.nl>).
|
from odoo import models, fields
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
from openerp import models, fields
|
|
||||||
|
|
||||||
|
|
||||||
class AccountBankStatement(models.Model):
|
class AccountBankStatement(models.Model):
|
||||||
|
|||||||
@@ -1,41 +1,28 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# © 2015 Therp BV (<http://therp.nl>).
|
||||||
#
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# This module copyright (C) 2015 Therp BV (<http://therp.nl>).
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
import base64
|
import base64
|
||||||
from openerp import models, api
|
from odoo import models, api
|
||||||
|
|
||||||
|
|
||||||
class AccountBankStatementImport(models.TransientModel):
|
class AccountBankStatementImport(models.TransientModel):
|
||||||
_inherit = 'account.bank.statement.import'
|
_inherit = 'account.bank.statement.import'
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _import_file(self, data_file):
|
def import_file(self):
|
||||||
(statement_ids, notifications) = \
|
action = \
|
||||||
super(AccountBankStatementImport, self)._import_file(data_file)
|
super(AccountBankStatementImport, self).import_file()
|
||||||
|
statement_ids = action.get('context', {}).get('statement_ids')
|
||||||
|
notifications = action.get('context', {}).get('notifications')
|
||||||
|
data_file = base64.b64decode(self.data_file)
|
||||||
if statement_ids:
|
if statement_ids:
|
||||||
self.env['account.bank.statement'].browse(statement_ids).write({
|
self.env['account.bank.statement'].browse(statement_ids).write({
|
||||||
'import_file': self.env['ir.attachment'].create(
|
'import_file': self.env['ir.attachment'].create(
|
||||||
self._create_import_file_attachment_data(
|
self._create_import_file_attachment_data(
|
||||||
data_file, statement_ids[0], notifications)).id,
|
data_file, statement_ids[0], notifications)).id,
|
||||||
})
|
})
|
||||||
return (statement_ids, notifications)
|
return action
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _create_import_file_attachment_data(self, data_file, statement_id,
|
def _create_import_file_attachment_data(self, data_file, statement_id,
|
||||||
|
|||||||
@@ -1,21 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# © 2015 Therp BV (<http://therp.nl>).
|
||||||
#
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# This module copyright (C) 2015 Therp BV <http://therp.nl>.
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
from . import test_save_file
|
from . import test_save_file
|
||||||
|
|||||||
@@ -1,26 +1,11 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# © 2015 Therp BV (<http://therp.nl>).
|
||||||
#
|
# © 2017 Today Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
|
||||||
# OpenERP, Open Source Management Solution
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
# This module copyright (C) 2015 Therp BV <http://therp.nl>.
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
import base64
|
import base64
|
||||||
from openerp import api, models
|
from odoo import api, models
|
||||||
from openerp.tests.common import TransactionCase
|
from odoo.tests.common import TransactionCase
|
||||||
|
|
||||||
|
|
||||||
acc_number = 'BE1234567890'
|
acc_number = 'BE1234567890'
|
||||||
@@ -48,31 +33,26 @@ class HelloWorldParser(models.TransientModel):
|
|||||||
|
|
||||||
|
|
||||||
class TestSaveFile(TransactionCase):
|
class TestSaveFile(TransactionCase):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestSaveFile, self).setUp()
|
||||||
|
self.currency_eur_id = self.env.ref("base.EUR").id
|
||||||
|
self.bank_journal_euro = self.env['account.journal'].create(
|
||||||
|
{'name': 'Bank',
|
||||||
|
'type': 'bank',
|
||||||
|
'code': 'BNK_test_imp',
|
||||||
|
'currency_id': self.currency_eur_id
|
||||||
|
})
|
||||||
|
|
||||||
def test_SaveFile(self):
|
def test_SaveFile(self):
|
||||||
HelloWorldParser._build_model(self.registry, self.cr)
|
HelloWorldParser._build_model(self.registry, self.cr)
|
||||||
import_wizard = self.env['account.bank.statement.import']
|
import_wizard = self.env['account.bank.statement.import']
|
||||||
import_wizard._prepare_setup()
|
journal_id = self.bank_journal_euro.id
|
||||||
import_wizard._setup_base(False)
|
import_wizard_id = import_wizard.with_context(journal_id=journal_id)\
|
||||||
import_wizard._setup_fields()
|
.create(
|
||||||
import_wizard._setup_complete()
|
{'data_file': base64.b64encode(bytes('Hello world'))})
|
||||||
import_wizard._auto_init()
|
action = import_wizard_id.import_file()
|
||||||
journal_id = self.env['res.partner.bank'].search([
|
|
||||||
('acc_number', '=', acc_number),
|
|
||||||
]).journal_id.id
|
|
||||||
if not journal_id:
|
|
||||||
account = import_wizard._create_bank_account(acc_number)
|
|
||||||
journal_id = self.env['account.journal']\
|
|
||||||
.search([
|
|
||||||
'|',
|
|
||||||
('currency.name', '=', 'EUR'),
|
|
||||||
('currency', '=', False)
|
|
||||||
]).ids[0]
|
|
||||||
account.journal_id = journal_id
|
|
||||||
action = import_wizard.with_context(journal_id=journal_id)\
|
|
||||||
.create({'data_file': base64.b64encode('hello world')})\
|
|
||||||
.import_file()
|
|
||||||
for statement in self.env['account.bank.statement'].browse(
|
for statement in self.env['account.bank.statement'].browse(
|
||||||
action['context']['statement_ids']):
|
action['context']['statement_ids']):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
base64.b64decode(statement.import_file.datas),
|
base64.b64decode(statement.import_file.datas),
|
||||||
'hello world')
|
'Hello world')
|
||||||
|
|||||||
@@ -1,25 +1,23 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<openerp>
|
<odoo>
|
||||||
<data>
|
<record id="view_bank_statement_form" model="ir.ui.view">
|
||||||
<record id="view_bank_statement_form" model="ir.ui.view">
|
<field name="model">account.bank.statement</field>
|
||||||
<field name="model">account.bank.statement</field>
|
<field name="inherit_id" ref="account.view_bank_statement_form" />
|
||||||
<field name="inherit_id" ref="account.view_bank_statement_form" />
|
<field name="arch" type="xml">
|
||||||
<field name="arch" type="xml">
|
<xpath expr="//page[@name='statement_line_ids']" position="after">
|
||||||
<xpath expr="//page[@string='Transactions']" position="after">
|
<page string="Imported file" attrs="{'invisible': [('import_file', '=', False)]}">
|
||||||
<page string="Imported file" attrs="{'invisible': [('import_file', '=', False)]}">
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<field name="import_file" />
|
||||||
<field name="import_file" />
|
|
||||||
</group>
|
|
||||||
<group>
|
|
||||||
<field name="import_date" />
|
|
||||||
<field name="import_user" />
|
|
||||||
</group>
|
|
||||||
</group>
|
</group>
|
||||||
<field name="import_log" />
|
<group>
|
||||||
</page>
|
<field name="import_date" />
|
||||||
</xpath>
|
<field name="import_user" />
|
||||||
</field>
|
</group>
|
||||||
</record>
|
</group>
|
||||||
</data>
|
<field name="import_log" />
|
||||||
</openerp>
|
</page>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
|
|||||||
Reference in New Issue
Block a user