← Back to team overview

banking-addons-team team mailing list archive

lp:~akretion-team/banking-addons/bank-statement-reconcile-61-repository into lp:banking-addons/bank-statement-reconcile-61

 

Benoit Guillot - http://www.akretion.com has proposed merging lp:~akretion-team/banking-addons/bank-statement-reconcile-61-repository into lp:banking-addons/bank-statement-reconcile-61.

Requested reviews:
  Banking Addons Core Editors (banking-addons-team)

For more details, see:
https://code.launchpad.net/~akretion-team/banking-addons/bank-statement-reconcile-61-repository/+merge/172366

This merge proposal adds a module to import bank statement automaticaly from a repository (ftp, sftp, ...)
This module uses a generic module : file_repository from the project : https://code.launchpad.net/file-exchange

Thanks
-- 
https://code.launchpad.net/~akretion-team/banking-addons/bank-statement-reconcile-61-repository/+merge/172366
Your team Banking Addons Core Editors is requested to review the proposed merge of lp:~akretion-team/banking-addons/bank-statement-reconcile-61-repository into lp:banking-addons/bank-statement-reconcile-61.
=== added directory 'account_statement_repository'
=== added file 'account_statement_repository/__init__.py'
--- account_statement_repository/__init__.py	1970-01-01 00:00:00 +0000
+++ account_statement_repository/__init__.py	2013-07-01 16:22:39 +0000
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#
+#   account_statement_repository for OpenERP
+#   Copyright (C) 2013 Akretion (http://www.akretion.com). All Rights Reserved
+#   @author Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>
+#
+#   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 file_document
+import abstract_task
+import file_repository

=== added file 'account_statement_repository/__openerp__.py'
--- account_statement_repository/__openerp__.py	1970-01-01 00:00:00 +0000
+++ account_statement_repository/__openerp__.py	2013-07-01 16:22:39 +0000
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#
+#   account_statement_repository for OpenERP
+#   Copyright (C) 2013 Akretion (http://www.akretion.com). All Rights Reserved
+#   @author Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>
+#
+#   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': 'account_statement_repository',
+    'version': '0.1',
+    'category': 'Generic Modules/Others',
+    'license': 'AGPL-3',
+    'description': """
+    This module use tasks created with the module file_repository to import automaticaly account statements.
+    The module file_repository is in the project : https://code.launchpad.net/file-exchange
+    """,
+    'author': 'Akretion',
+    'website': 'http://www.akretion.com/',
+    'depends': ['file_repository',
+                'account_statement_base_import',
+                ],
+    'init_xml': [],
+    'update_xml': [
+           'file_document_view.xml',
+           'file_repository_view.xml',
+    ],
+    'demo_xml': [],
+    'installable': True,
+    'active': False,
+}

=== added file 'account_statement_repository/abstract_task.py'
--- account_statement_repository/abstract_task.py	1970-01-01 00:00:00 +0000
+++ account_statement_repository/abstract_task.py	2013-07-01 16:22:39 +0000
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#
+#   account_statement_repository for OpenERP
+#   Copyright (C) 2013 Akretion (http://www.akretion.com). All Rights Reserved
+#   @author Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>
+#
+#   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.osv import orm
+
+
+class automatic_task(orm.Model):
+    _inherit = "automatic.task"
+
+    def get_task_type(self, cr, uid, context=None):
+        res = super(automatic_task, self).get_task_type(cr, uid, context=context)
+        res.append(('bank_statement', 'Bank Statement Import'))
+        return res
+

=== added file 'account_statement_repository/file_document.py'
--- account_statement_repository/file_document.py	1970-01-01 00:00:00 +0000
+++ account_statement_repository/file_document.py	2013-07-01 16:22:39 +0000
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#
+#   account_statement_repository for OpenERP
+#   Copyright (C) 2013 Akretion (http://www.akretion.com). All Rights Reserved
+#   @author Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>
+#
+#   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.osv import fields, orm
+import os
+
+
+class file_document(orm.Model):
+    _inherit = "file.document"
+
+    def get_file_document_type(self, cr, uid, context=None):
+        res = super(file_document, self).get_file_document_type(cr, uid, context=context)
+        res.append(('bank_statement', 'Bank Statement Import'))
+        return res
+
+    _columns = {
+        'statement_profile_id': fields.many2one('account.statement.profile',
+                                                string='Account Statement Profile')
+    }
+
+    def _run(self, cr, uid, filedocument, context=None):
+        super(file_document, self)._run(cr, uid, filedocument, context=context)
+        acc_profile_obj = self.pool['account.statement.profile']
+        attach_obj = self.pool['ir.attachment']
+        if filedocument.file_type == 'bank_statement':
+            (shortname, ftype) = os.path.splitext(filedocument.name)
+            acc_profile_obj.statement_import(
+                                            cr,
+                                            uid,
+                                            False,
+                                            filedocument.statement_profile_id.id,
+                                            filedocument.datas,
+                                            ftype.replace('.', ''),
+                                            context=context
+                                        )
\ No newline at end of file

=== added file 'account_statement_repository/file_document_view.xml'
--- account_statement_repository/file_document_view.xml	1970-01-01 00:00:00 +0000
+++ account_statement_repository/file_document_view.xml	2013-07-01 16:22:39 +0000
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!-- INHERITED VIEW FOR THE OBJECT : file_document -->
+
+        <record id="file_document_view_form" model="ir.ui.view">
+            <field name="name">bank_statement_repository.file_document.view_form</field>
+            <field name="model">file.document</field>
+            <field name="inherit_id" ref="file_repository.file_document_view_form" />
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <data>
+                    <field name="file_type" position="after">
+                        <field name="statement_profile_id"
+                               attrs="{'invisible':[('file_type', '!=', 'bank_statement')],
+                                       'required':[('file_type', '=', 'bank_statement')]}"/>
+                    </field>
+                </data>
+            </field>
+        </record>
+
+    </data>
+</openerp>

=== added file 'account_statement_repository/file_repository.py'
--- account_statement_repository/file_repository.py	1970-01-01 00:00:00 +0000
+++ account_statement_repository/file_repository.py	2013-07-01 16:22:39 +0000
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#
+#   account_statement_repository for OpenERP
+#   Copyright (C) 2013 Akretion (http://www.akretion.com). All Rights Reserved
+#   @author Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>
+#
+#   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.osv import fields, orm
+
+
+class repository_task(orm.Model):
+    _inherit = "repository.task"
+
+    _columns = {
+        'statement_profile_id': fields.many2one('account.statement.profile',
+                                                string='Account Statement Profile')
+    }
+
+    def prepare_document_vals(self, cr, uid, task, file_name, datas, context=None):
+        vals = super(repository_task, self).prepare_document_vals(cr, uid,
+                                                                  task,
+                                                                  file_name,
+                                                                  datas,
+                                                                  context=context)
+        if task.type == 'bank_statement':
+            vals.update({'file_type': task.type,
+                         'statement_profile_id': task.statement_profile_id.id})
+        return vals

=== added file 'account_statement_repository/file_repository_view.xml'
--- account_statement_repository/file_repository_view.xml	1970-01-01 00:00:00 +0000
+++ account_statement_repository/file_repository_view.xml	2013-07-01 16:22:39 +0000
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!-- INHERITED VIEW FOR THE OBJECT : repository_task -->
+
+        <record id="view_repository_task_form" model="ir.ui.view">
+            <field name="name">bank_statement_repository.repository_task.view_form</field>
+            <field name="model">repository.task</field>
+            <field name="inherit_id" ref="file_repository.view_repository_task_form" />
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <data>
+                    <field name="active" position="after">
+                        <field name="statement_profile_id"
+                               attrs="{'invisible':[('type', '!=', 'bank_statement')],
+                                       'required':[('type', '=', 'bank_statement')]}"/>
+                    </field>
+                </data>
+            </field>
+        </record>
+
+    </data>
+</openerp>


Follow ups