Merge lp:~openerp-dev/openobject-addons/trunk-import-bank-statements into lp:openobject-addons

Proposed by DJ Patel (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-import-bank-statements
Merge into: lp:openobject-addons
Diff against target: 817 lines (+520/-103)
19 files modified
account/__init__.py (+1/-0)
account/__openerp__.py (+1/-1)
account/account_bank_statement_import.py (+118/-0)
account/account_bank_statement_import_view.xml (+47/-0)
account/tests/__init__.py (+4/-0)
account/tests/test_import_bank_statement.py (+73/-0)
account/wizard/account_financial_report.py (+1/-1)
account_qif/__init__.py (+24/-0)
account_qif/__openerp__.py (+49/-0)
account_qif/account_qif.py (+96/-0)
account_qif/tests/__init__.py (+4/-0)
account_qif/tests/test_import_bank_statement.py (+30/-0)
l10n_be_coda/__openerp__.py (+0/-1)
l10n_be_coda/l10n_be_coda_view.xml (+1/-2)
l10n_be_coda/l10n_be_coda_wizard.xml (+0/-35)
l10n_be_coda/test_coda_file/Ontvangen_CODA.2013-01-11-18.59.15.txt (+11/-11)
l10n_be_coda/tests/__init__.py (+4/-0)
l10n_be_coda/tests/test_import_bank_statement.py (+39/-0)
l10n_be_coda/wizard/account_coda_import.py (+17/-52)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-import-bank-statements
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+212993@code.launchpad.net

Description of the change

Hello,

I have created a generic wizard for ofx, qif and coda file format.
It is used to import these types of bank statements into openerp.

Thanks,
Divyesh

To post a comment you must log in.
9257. By DJ Patel (OpenERP)

[IMP] account : Improved the code to return an action.

9258. By DJ Patel (OpenERP)

[FIX] account, account_qif, l10n_be_coda : Fixed the test cases.

9259. By DJ Patel (OpenERP)

[Merge] Merged with trunk.

9260. By DJ Patel (OpenERP)

[Merge] Merged with trunk.

9261. By DJ Patel (OpenERP)

[Merge] Merged with trunk.

9262. By DJ Patel (OpenERP)

[Merge] Merged with trunk.

Unmerged revisions

9262. By DJ Patel (OpenERP)

[Merge] Merged with trunk.

9261. By DJ Patel (OpenERP)

[Merge] Merged with trunk.

9260. By DJ Patel (OpenERP)

[Merge] Merged with trunk.

9259. By DJ Patel (OpenERP)

[Merge] Merged with trunk.

9258. By DJ Patel (OpenERP)

[FIX] account, account_qif, l10n_be_coda : Fixed the test cases.

9257. By DJ Patel (OpenERP)

[IMP] account : Improved the code to return an action.

9256. By DJ Patel (OpenERP)

[Merge] Merged the branch: lp:~openerp-dev/openobject-addons/trunk-import-bank-statement with improvements.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account/__init__.py'
--- account/__init__.py 2012-11-29 22:26:45 +0000
+++ account/__init__.py 2014-04-02 04:28:41 +0000
@@ -38,5 +38,6 @@
38import res_currency38import res_currency
39import edi39import edi
40import res_config40import res_config
41import account_bank_statement_import
4142
42# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:43# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
4344
=== modified file 'account/__openerp__.py'
--- account/__openerp__.py 2014-02-13 17:39:10 +0000
+++ account/__openerp__.py 2014-04-02 04:28:41 +0000
@@ -124,7 +124,7 @@
124 'account_bank_view.xml',124 'account_bank_view.xml',
125 'res_config_view.xml',125 'res_config_view.xml',
126 'account_pre_install.yml',126 'account_pre_install.yml',
127127 'account_bank_statement_import_view.xml',
128 'views/report_vat.xml',128 'views/report_vat.xml',
129 ],129 ],
130 'js': [130 'js': [
131131
=== added file 'account/account_bank_statement_import.py'
--- account/account_bank_statement_import.py 1970-01-01 00:00:00 +0000
+++ account/account_bank_statement_import.py 2014-04-02 04:28:41 +0000
@@ -0,0 +1,118 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import logging
23import base64
24import os
25import time
26
27from openerp.osv import fields, osv
28from openerp.tools.translate import _
29from openerp import tools
30
31_logger = logging.getLogger(__name__)
32
33try:
34 from ofxparse import OfxParser as ofxparser
35except ImportError:
36 _logger.warning("OFX parser partially unavailable because the `ofxparse` Python library cannot be found. "
37 "It can be easily download and install from this `https://pypi.python.org/pypi/ofxparse`.")
38 ofxparser = None
39
40_IMPORT_FILE_TYPE = [('ofx', 'OFX')]
41
42class account_bank_statement_import(osv.TransientModel):
43 _name = 'account.bank.statement.import'
44 _description = 'Import Bank Statement'
45 _columns = {
46 'data_file': fields.binary('Bank Statement File', required=True, help='Select bank statement file to import in OpenERP. .OFX, .QIF or CODA are accepted.'),
47 'file_type': fields.selection(_IMPORT_FILE_TYPE, 'File Type'),
48 'journal_id': fields.many2one('account.journal', 'Journal', required=True),
49 'account_id': fields.many2one('account.account', 'Account', domain="[('type', '!=', 'view')]", help=" Choose the account to be credited/debited for the entries of the statement.", required=True),
50 }
51
52 def _get_default_journal(self, cr, uid, context=None):
53 company_id = self.pool.get('res.company')._company_default_get(cr, uid, 'account.bank.statement', context=context)
54 journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'bank'), ('company_id', '=', company_id)], context=context)
55 return journal_ids and journal_ids[0] or False
56
57 _defaults = {
58 'file_type': 'ofx',
59 'journal_id': _get_default_journal,
60 }
61
62 def import_bank_statement(self, cr, uid, bank_statement_vals=False, context=None):
63 statement_id = self.pool.get('account.bank.statement').create(cr, uid, bank_statement_vals, context=context)
64 return statement_id
65
66 def process_ofx(self, cr, uid, data_file, journal_id=False, account_id=False, context=None):
67 try:
68 tempfile = open( "temp.ofx", "w+" )
69 tempfile.write(base64.decodestring(data_file))
70 tempfile.read()
71 pathname = os.path.dirname('temp.ofx')
72 path = os.path.join(os.path.abspath(pathname), 'temp.ofx')
73 ofx = ofxparser.parse(file(path))
74 except:
75 raise osv.except_osv(_('Import Error!'), _('Please check OFX file format is proper or not.'))
76 line_ids = []
77 total_amt = 0.00
78 try:
79 for transaction in ofx.account.statement.transactions:
80 vals_line = {
81 'date' : transaction.date,
82 'name' : transaction.memo,
83 'ref': transaction.id,
84 'amount' : transaction.amount,
85 'account_id': account_id
86 }
87 total_amt += float(transaction.amount)
88 line_ids.append((0, 0, vals_line))
89 except Exception,e:
90 raise osv.except_osv(_('Error!'), _("Following problem has been occurred while importing your file, Please verify the file is proper or not.\n\n %s" % e.message))
91 st_start_date = ofx.account.statement.start_date or False
92 st_end_date = ofx.account.statement.end_date or False
93 period_obj = self.pool.get('account.period')
94 if st_end_date:
95 period_ids = period_obj.find(cr, uid, st_end_date, context=context)
96 else:
97 period_ids = period_obj.find(cr, uid, st_start_date, context=context)
98 vals_bank_statement = {
99 'name': ofx.account.routing_number,
100 'balance_start': ofx.account.statement.balance,
101 'balance_end_real': float(ofx.account.statement.balance) + total_amt,
102 'period_id': period_ids and period_ids[0] or False,
103 'journal_id': journal_id
104 }
105 vals_bank_statement.update({'line_ids': line_ids})
106 os.remove(path)
107 return vals_bank_statement
108
109 def parse_file(self, cr, uid, ids, context=None):
110 data = self.browse(cr, uid, ids[0], context=context)
111 vals = getattr(self, "process_%s" % data.file_type)(cr, uid, data.data_file, data.journal_id.id, data.account_id.id, context=context)
112 statement_id = self.import_bank_statement(cr, uid, vals, context=context)
113 model, action_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'action_bank_statement_tree')
114 action = self.pool[model].read(cr, uid, action_id, context=context)
115 action['domain'] = "[('id', 'in', ["+', '.join(map(str, [statement_id]))+"])]"
116 return action
117
118# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0119
=== added file 'account/account_bank_statement_import_view.xml'
--- account/account_bank_statement_import_view.xml 1970-01-01 00:00:00 +0000
+++ account/account_bank_statement_import_view.xml 2014-04-02 04:28:41 +0000
@@ -0,0 +1,47 @@
1<?xml version="1.0" ?>
2<openerp>
3 <data>
4
5 <record id="account_bank_statement_import_view" model="ir.ui.view">
6 <field name="name">Import Bank Statements</field>
7 <field name="model">account.bank.statement.import</field>
8 <field name="priority">1</field>
9 <field name="arch" type="xml">
10 <form string="Import Bank Statements" version="7.0">
11 <group>
12 <group>
13 <field name="file_type" required="1"/>
14 <field name="data_file" attrs="{'invisible':[('file_type','=',False)]}"/>
15 <field name="journal_id" domain="[('type', '=', 'bank')]" attrs="{'invisible':[('file_type','=',False)]}" context="{'default_type':'bank'}"/>
16 <field name="account_id" attrs="{'invisible':[('file_type','=',False)]}"/>
17 </group>
18 <group>
19 <b colspan="2"> How to import your bank statement in OpenERP.</b>
20 <label string= "1. Go to your bank account website." colspan="2"/>
21 <label string= "2. Download your bank statements in the right format. (.OFX, .QIF or CODA are accepted)" colspan="2"/>
22 <label string= "3. Upload right here the bank statements file into OpenERP. Click Import." colspan="2"/>
23 </group>
24 </group>
25 <footer>
26 <button name="parse_file" string="_Import" type="object" class="oe_highlight"/>
27 or
28 <button string="Cancel" class="oe_link" special="cancel"/>
29 </footer>
30 </form>
31 </field>
32 </record>
33
34 <record id="action_account_bank_statement_import" model="ir.actions.act_window">
35 <field name="name">Import Bank Statements</field>
36 <field name="type">ir.actions.act_window</field>
37 <field name="res_model">account.bank.statement.import</field>
38 <field name="view_type">form</field>
39 <field name="view_mode">form</field>
40 <field name="target">new</field>
41 <field name="view_id" ref="account_bank_statement_import_view"/>
42 </record>
43
44 <menuitem parent="account.menu_finance_bank_and_cash" id="menu_account_bank_statement_import" action="action_account_bank_statement_import" sequence="11"/>
45
46 </data>
47</openerp>
048
=== modified file 'account/tests/__init__.py'
--- account/tests/__init__.py 2013-12-06 17:00:12 +0000
+++ account/tests/__init__.py 2014-04-02 04:28:41 +0000
@@ -1,7 +1,11 @@
1from . import test_tax1from . import test_tax
2from . import test_import_bank_statement
2from . import test_search3from . import test_search
34
4fast_suite = [5fast_suite = [
5 test_tax,6 test_tax,
6 test_search,7 test_search,
7]8]
9checks = [
10 test_import_bank_statement
11]
812
=== added file 'account/tests/test_import_bank_statement.py'
--- account/tests/test_import_bank_statement.py 1970-01-01 00:00:00 +0000
+++ account/tests/test_import_bank_statement.py 2014-04-02 04:28:41 +0000
@@ -0,0 +1,73 @@
1from openerp.tests.common import TransactionCase
2
3ofx_file = """PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iQVNDSUkiPz4NCjw/
4 T0ZYIE9GWEhFQURFUj0iMjAwIiBWRVJTSU9OPSIyMTEiIFNFQ1VSSVRZPSJOT05FIiBPTE
5 RGSUxFVUlEPSJOT05FIiBORVdGSUxFVUlEPSJOT05FIj8+DQo8T0ZYPg0KICA8U0lHTk9O
6 TVNHU1JTVjE+DQogICAgPFNPTlJTPg0KICAgICAgPFNUQVRVUz4NCiAgICAgICAgPENPRE
7 U+MDwvQ09ERT4NCiAgICAgICAgPFNFVkVSSVRZPklORk88L1NFVkVSSVRZPg0KICAgICAg
8 PC9TVEFUVVM+DQogICAgICA8RFRTRVJWRVI+MjAwNTA4MzExNjUxNTMuMDAwWy04OlBTVF
9 08L0RUU0VSVkVSPg0KICAgICAgPExBTkdVQUdFPkVORzwvTEFOR1VBR0U+DQogICAgPC9T
10 T05SUz4NCiAgPC9TSUdOT05NU0dTUlNWMT4NCiAgPEJBTktNU0dTUlNWMT4NCiAgICA8U1
11 RNVFRSTlJTPg0KICAgICAgPFRSTlVJRD4wPC9UUk5VSUQ+DQogICAgICA8U1RBVFVTPg0K
12 ICAgICAgICA8Q09ERT4wPC9DT0RFPg0KICAgICAgICA8U0VWRVJJVFk+SU5GTzwvU0VWRV
13 JJVFk+DQogICAgICA8L1NUQVRVUz4NCiAgICAgIDxTVE1UUlM+DQogICAgICAgIDxDVVJE
14 RUY+VVNEPC9DVVJERUY+DQogICAgICAgIDxCQU5LQUNDVEZST00+DQogICAgICAgICAgPE
15 JBTktJRD4wMDAwMDAxMjM8L0JBTktJRD4NCiAgICAgICAgICA8QUNDVElEPjEyMzQ1Njwv
16 QUNDVElEPg0KICAgICAgICAgIDxBQ0NUVFlQRT5DSEVDS0lORzwvQUNDVFRZUEU+DQogIC
17 AgICAgIDwvQkFOS0FDQ1RGUk9NPg0KICAgICAgICA8QkFOS1RSQU5MSVNUPg0KICAgICAg
18 ICAgIDxEVFNUQVJUPjIwMTQwODAxPC9EVFNUQVJUPg0KICAgICAgICAgIDxEVEVORD4yMD
19 E0MDgzMTE2NTE1My4wMDBbLTg6UFNUXTwvRFRFTkQ+DQogICAgICAgICAgPFNUTVRUUk4+
20 DQogICAgICAgICAgICA8VFJOVFlQRT5QT1M8L1RSTlRZUEU+DQogICAgICAgICAgICA8RF
21 RQT1NURUQ+MjAwNTA4MjQwODAwMDA8L0RUUE9TVEVEPg0KICAgICAgICAgICAgPFRSTkFN
22 VD4tODA8L1RSTkFNVD4NCiAgICAgICAgICAgIDxGSVRJRD4yMTkzNzg8L0ZJVElEPg0KIC
23 AgICAgICAgICAgPE5BTUU+RnJvZ0tpY2sgU2N1YmEgR2VhcjwvTkFNRT4NCiAgICAgICAg
24 ICA8L1NUTVRUUk4+DQogICAgICAgIDwvQkFOS1RSQU5MSVNUPg0KICAgICAgICA8TEVER0
25 VSQkFMPg0KICAgICAgICAgIDxCQUxBTVQ+MjE1Ni41NjwvQkFMQU1UPg0KICAgICAgICAg
26 IDxEVEFTT0Y+MjAwNTA4MzExNjUxNTM8L0RUQVNPRj4NCiAgICAgICAgPC9MRURHRVJCQU
27 w+DQogICAgICA8L1NUTVRSUz4NCiAgICA8L1NUTVRUUk5SUz4NCiAgPC9CQU5LTVNHU1JT
28 VjE+DQogIDxDUkVESVRDQVJETVNHU1JTVjE+DQogICAgPENDU1RNVFRSTlJTPg0KICAgIC
29 AgPFRSTlVJRD4wPC9UUk5VSUQ+DQogICAgICA8U1RBVFVTPg0KICAgICAgICA8Q09ERT4w
30 PC9DT0RFPg0KICAgICAgICA8U0VWRVJJVFk+SU5GTzwvU0VWRVJJVFk+DQogICAgICA8L1
31 NUQVRVUz4NCiAgICAgIDxDQ1NUTVRSUz4NCiAgICAgICAgPENVUkRFRj5VU0Q8L0NVUkRF
32 Rj4NCiAgICAgICAgPENDQUNDVEZST00+DQogICAgICAgICAgPEFDQ1RJRD4xMjM0MTIzND
33 EyMzQ8L0FDQ1RJRD4NCiAgICAgICAgPC9DQ0FDQ1RGUk9NPg0KICAgICAgICA8QkFOS1RS
34 QU5MSVNUPg0KICAgICAgICAgIDxEVFNUQVJUPjIwMTQwODAxPC9EVFNUQVJUPg0KICAgIC
35 AgICAgIDxEVEVORD4yMDE0MDgzMTE2NTE1My4wMDBbLTg6UFNUXTwvRFRFTkQ+DQogICAg
36 ICAgICAgPFNUTVRUUk4+DQogICAgICAgICAgICA8VFJOVFlQRT5JTlQ8L1RSTlRZUEU+DQ
37 ogICAgICAgICAgICA8RFRQT1NURUQ+MjAwNTA4MTEwODAwMDA8L0RUUE9TVEVEPg0KICAg
38 ICAgICAgICAgPFRSTkFNVD4tMjMuMDA8L1RSTkFNVD4NCiAgICAgICAgICAgIDxGSVRJRD
39 4yMTk4Njc8L0ZJVElEPg0KICAgICAgICAgICAgPE5BTUU+SW50ZXJlc3QgQ2hhcmdlPC9O
40 QU1FPg0KICAgICAgICAgIDwvU1RNVFRSTj4NCiAgICAgICAgICA8U1RNVFRSTj4NCiAgIC
41 AgICAgICAgIDxUUk5UWVBFPkNSRURJVDwvVFJOVFlQRT4NCiAgICAgICAgICAgIDxEVFBP
42 U1RFRD4yMDA1MDgxMTA4MDAwMDwvRFRQT1NURUQ+DQogICAgICAgICAgICA8VFJOQU1UPj
43 M1MC4wMDwvVFJOQU1UPg0KICAgICAgICAgICAgPEZJVElEPjIxOTg2ODwvRklUSUQ+DQog
44 ICAgICAgICAgICA8TkFNRT5QYXltZW50IC0gVGhhbmsgWW91PC9OQU1FPg0KICAgICAgIC
45 AgIDwvU1RNVFRSTj4NCiAgICAgICAgPC9CQU5LVFJBTkxJU1Q+DQogICAgICAgIDxMRURH
46 RVJCQUw+DQogICAgICAgICAgPEJBTEFNVD4tNTYyLjAwPC9CQUxBTVQ+DQogICAgICAgIC
47 AgPERUQVNPRj4yMDA1MDgzMTE2NTE1MzwvRFRBU09GPg0KICAgICAgICA8L0xFREdFUkJB
48 TD4NCiAgICAgIDwvQ0NTVE1UUlM+DQogICAgPC9DQ1NUTVRUUk5SUz4NCiAgPC9DUkVESV
49 RDQVJETVNHU1JTVjE+DQo8L09GWD4NCg=="""
50
51class TestOfxFile(TransactionCase):
52 """Tests for import bank statement ofx file format (account.bank.statement.import)
53 """
54
55 def setUp(self):
56 super(TestOfxFile, self).setUp()
57 self.statement_import_model = self.registry('account.bank.statement.import')
58 self.bank_statement_model = self.registry('account.bank.statement')
59
60 def test_ofx_file_import(self):
61 cr, uid = self.cr, self.uid
62 bank_temp_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'account', 'conf_bnk')
63 self.bank_temp_id = bank_temp_ref and bank_temp_ref[1] or False
64 bank_statement_id = self.statement_import_model.create(cr, uid, dict(
65 file_type = 'ofx',
66 data_file = ofx_file,
67 account_id = self.bank_temp_id
68 ))
69 self.statement_import_model.parse_file(cr, uid, [bank_statement_id])
70 statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '000000123')])[0]
71 bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id)
72 self.assertEquals(bank_st_record.balance_start, 2156.56)
73 self.assertEquals(bank_st_record.balance_end_real, 2076.56)
074
=== modified file 'account/wizard/account_financial_report.py'
--- account/wizard/account_financial_report.py 2013-10-27 12:31:04 +0000
+++ account/wizard/account_financial_report.py 2014-04-02 04:28:41 +0000
@@ -2,7 +2,7 @@
2##############################################################################2##############################################################################
3#3#
4# OpenERP, Open Source Management Solution4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).5# Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>).
6#6#
7# This program is free software: you can redistribute it and/or modify7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as8# it under the terms of the GNU Affero General Public License as
99
=== added directory 'account_qif'
=== added file 'account_qif/__init__.py'
--- account_qif/__init__.py 1970-01-01 00:00:00 +0000
+++ account_qif/__init__.py 2014-04-02 04:28:41 +0000
@@ -0,0 +1,24 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import account_qif
23
24# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
025
=== added file 'account_qif/__openerp__.py'
--- account_qif/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_qif/__openerp__.py 2014-04-02 04:28:41 +0000
@@ -0,0 +1,49 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22{
23 'name': 'Import QIF Bank Statement',
24 'version': '1.1',
25 'author': 'OpenERP SA',
26 'category': 'Accounting & Finance',
27 'description': '''
28Module to import QIF bank statements.
29======================================
30
31The machine readable QIF Files are parsed and stored in human readable format in
32Bank Statements. Also Bank Statements are generated containing a subset of
33the QIF information (only those transaction lines that are required for the
34creation of the Financial Accounting records). The Bank Statement is a
35'read-only' object, hence remaining a reliable representation of the original
36QIF file whereas the Bank Statement will get modified as required by accounting
37business processes.
38
39QIF Bank Accounts configured as type 'QIF' will only generate QIF Bank Statements.
40''',
41 'images' : [],
42 'depends': ['account'],
43 'demo': [],
44 'data': [],
45 'auto_install': False,
46 'installable': True,
47}
48
49# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
050
=== added file 'account_qif/account_qif.py'
--- account_qif/account_qif.py 1970-01-01 00:00:00 +0000
+++ account_qif/account_qif.py 2014-04-02 04:28:41 +0000
@@ -0,0 +1,96 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import dateutil.parser
23import base64
24import logging
25from tempfile import TemporaryFile
26
27from openerp.tools.translate import _
28from openerp.osv import fields, osv
29from openerp import tools
30
31_logger = logging.getLogger(__name__)
32
33from openerp.addons.account import account_bank_statement_import as ibs
34
35ibs._IMPORT_FILE_TYPE.append(('qif', 'QIF'))
36
37class account_bank_statement_import(osv.TransientModel):
38 _inherit = "account.bank.statement.import"
39
40 _columns = {
41 'file_type': fields.selection(ibs._IMPORT_FILE_TYPE, 'File Type'),
42 }
43
44 def process_qif(self, cr, uid, data_file, journal_id=False, account_id=False, context=None):
45 try:
46 fileobj = TemporaryFile('wb+')
47 fileobj.write(base64.b64decode(data_file))
48 fileobj.seek(0)
49 file_data = ""
50 for line in fileobj.readlines():
51 file_data += line
52 fileobj.close()
53 if '\r' in file_data:
54 data_list = file_data.split('\r')
55 else:
56 data_list = file_data.split('\n')
57 header = data_list[0].strip()
58 header = header.split(":")[1]
59 except:
60 raise osv.except_osv(_('Import Error!'), _('Please check QIF file format is proper or not.'))
61 line_ids = []
62 vals_line = {}
63 total = 0
64 if header == "Bank":
65 vals_bank_statement = {}
66 for line in data_list:
67 line = line.strip()
68 if not line: continue
69 if line[0] == 'D': # date of transaction
70 vals_line['date'] = dateutil.parser.parse(line[1:], fuzzy=True).date()
71 if vals_line.get('date'):
72 period_ids = self.pool.get('account.period').find(cr, uid, vals_line['date'], context=context)
73 vals_bank_statement.update({'period_id': period_ids and period_ids[0] or False})
74 elif line[0] == 'T': # Total amount
75 total += float(line[1:].replace(',', ''))
76 vals_line['amount'] = float(line[1:].replace(',', ''))
77 elif line[0] == 'N': # Check number
78 vals_line['ref'] = line[1:]
79 elif line[0] == 'P': # Payee
80 vals_line['name'] = line[1:]
81 elif line[0] == '^': # end of item
82 vals_line['account_id'] = account_id
83 line_ids.append((0, 0, vals_line))
84 vals_line = {}
85 elif line[0] == '\n':
86 line_ids = []
87 else:
88 pass
89 else:
90 raise osv.except_osv(_('Error!'), _('Cannot support this Format !Type:%s.') % (header,))
91 vals_bank_statement.update({'balance_end_real': total,
92 'line_ids': line_ids,
93 'journal_id': journal_id})
94 return vals_bank_statement
95
96# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
097
=== added directory 'account_qif/tests'
=== added file 'account_qif/tests/__init__.py'
--- account_qif/tests/__init__.py 1970-01-01 00:00:00 +0000
+++ account_qif/tests/__init__.py 2014-04-02 04:28:41 +0000
@@ -0,0 +1,4 @@
1from . import test_import_bank_statement
2checks = [
3 test_import_bank_statement
4]
05
=== added file 'account_qif/tests/test_import_bank_statement.py'
--- account_qif/tests/test_import_bank_statement.py 1970-01-01 00:00:00 +0000
+++ account_qif/tests/test_import_bank_statement.py 2014-04-02 04:28:41 +0000
@@ -0,0 +1,30 @@
1from openerp.tests.common import TransactionCase
2
3qif_file = """IVR5cGU6QmFuawpEOC8xMi8xNApULTEsMDAwLjAwClBGcmFua3MgUGx1bWJpbmcKXgpEOC8xNS8xNApULTc1L
4 jQ2ClBXYWx0cyBEcnVncwpeCkQzLzMvMTQKVC0zNzkuMDAKUENJVFkgT0YgU1BSSU5HRklFTEQKXgpEMy80LzE0ClQtMjAuM
5 jgKUFlPVVIgTE9DQUwgU1VQRVJNQVJLRVQKXgpEMy8zLzE0ClQtNDIxLjM1ClBTUFJJTkdGSUVMRCBXQVRFUiBVVElMSVRZCl4K"""
6
7class TestQifFile(TransactionCase):
8 """Tests for import bank statement qif file format (account.bank.statement.import)
9 """
10
11 def setUp(self):
12 super(TestQifFile, self).setUp()
13 self.statement_import_model = self.registry('account.bank.statement.import')
14 self.bank_statement_model = self.registry('account.bank.statement')
15 self.bank_statement_line_model = self.registry('account.bank.statement.line')
16
17 def test_qif_file_import(self):
18 cr, uid = self.cr, self.uid
19 bank_temp_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'account', 'conf_bnk')
20 self.bank_temp_id = bank_temp_ref and bank_temp_ref[1] or False
21 bank_statement_id = self.statement_import_model.create(cr, uid, dict(
22 file_type = 'qif',
23 data_file = qif_file,
24 account_id = self.bank_temp_id
25 ))
26 self.statement_import_model.parse_file(cr, uid, [bank_statement_id])
27 line_id = self.bank_statement_line_model.search(cr, uid, [('name', '=', 'YOUR LOCAL SUPERMARKET')])[0]
28 statement_id = self.bank_statement_line_model.browse(cr, uid, line_id).statement_id.id
29 bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id)
30 self.assertEquals(bank_st_record.balance_end_real, -1896.09)
031
=== modified file 'l10n_be_coda/__openerp__.py'
--- l10n_be_coda/__openerp__.py 2012-12-06 11:18:16 +0000
+++ l10n_be_coda/__openerp__.py 2014-04-02 04:28:41 +0000
@@ -93,7 +93,6 @@
93 'depends': ['account_voucher','base_iban', 'l10n_be_invoice_bba',],93 'depends': ['account_voucher','base_iban', 'l10n_be_invoice_bba',],
94 'demo': [],94 'demo': [],
95 'data': [95 'data': [
96 'l10n_be_coda_wizard.xml',
97 'l10n_be_coda_view.xml',96 'l10n_be_coda_view.xml',
98 ],97 ],
99 'auto_install': False,98 'auto_install': False,
10099
=== modified file 'l10n_be_coda/l10n_be_coda_view.xml'
--- l10n_be_coda/l10n_be_coda_view.xml 2013-10-27 12:31:04 +0000
+++ l10n_be_coda/l10n_be_coda_view.xml 2014-04-02 04:28:41 +0000
@@ -93,6 +93,5 @@
93 </record>93 </record>
9494
95 <menuitem name="Bank Statement Lines" parent="account.menu_finance_bank_and_cash" id="menu_account_bank_statement_line_coda" action="action_account_bank_statement_line_coda" sequence="8" groups="base.group_no_one"/>95 <menuitem name="Bank Statement Lines" parent="account.menu_finance_bank_and_cash" id="menu_account_bank_statement_line_coda" action="action_account_bank_statement_line_coda" sequence="8" groups="base.group_no_one"/>
96 <menuitem name="Import CODA File" parent="account.menu_finance_bank_and_cash" id="menu_account_coda_import" action="action_account_coda_import" sequence="10"/>
97 </data> 96 </data>
98</openerp>
99\ No newline at end of file97\ No newline at end of file
98</openerp>
10099
=== removed file 'l10n_be_coda/l10n_be_coda_wizard.xml'
--- l10n_be_coda/l10n_be_coda_wizard.xml 2012-12-20 14:52:27 +0000
+++ l10n_be_coda/l10n_be_coda_wizard.xml 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
1<?xml version="1.0" ?>
2<openerp>
3 <data>
4
5 <record id="account_coda_import_view" model="ir.ui.view">
6 <field name="name">Import CODA File</field>
7 <field name="model">account.coda.import</field>
8 <field name="priority">1</field>
9 <field name="arch" type="xml">
10 <form string="Import CODA File" version="7.0">
11 <group col="2">
12 <field name="coda_data" filename="coda_fname"/>
13 <field name="temporary_account_id" />
14 </group>
15 <footer>
16 <button name="coda_parsing" string="_Import" type="object" class="oe_highlight"/>
17 or
18 <button string="Cancel" class="oe_link" special="cancel"/>
19 </footer>
20 </form>
21 </field>
22 </record>
23
24 <record id="action_account_coda_import" model="ir.actions.act_window">
25 <field name="name">Import CODA File</field>
26 <field name="type">ir.actions.act_window</field>
27 <field name="res_model">account.coda.import</field>
28 <field name="view_type">form</field>
29 <field name="view_mode">form</field>
30 <field name="target">new</field>
31 <field name="view_id" ref="account_coda_import_view"/>
32 </record>
33
34 </data>
35</openerp>
360
=== renamed file 'l10n_be_coda/test_coda_file/Ontvangen_CODA.2011-01-11-18.59.15.txt' => 'l10n_be_coda/test_coda_file/Ontvangen_CODA.2013-01-11-18.59.15.txt'
--- l10n_be_coda/test_coda_file/Ontvangen_CODA.2011-01-11-18.59.15.txt 2012-01-31 13:36:57 +0000
+++ l10n_be_coda/test_coda_file/Ontvangen_CODA.2013-01-11-18.59.15.txt 2014-04-02 04:28:41 +0000
@@ -1,24 +1,24 @@
10000011011172505 00178299 DE MEYER LUC KREDBEBB 00820512013 00000 210000011011472505 00178299 DE MEYER LUC KREDBEBB 00820512014 00000 2
212135BE33737018595246 EUR0000000011812700270710NOVIAT NV KBC-Business Comfortrekening 003212135BE33737018595246 EUR0000000011812700270710NOVIAT NV KBC-Business Comfortrekening 003
32100010000OL44483FW SCTOFBIONLO1000000000435000110111001010000MEDEDELING 11011113501 032100010000OL44483FW SCTOFBIONLO1000000000435000110114001010000MEDEDELING 11011413501 0
42200010000 GKCCBEBB 1 042200010000 GKCCBEBB 1 0
52300010000BE41063012345610 PARTNER 1 0 152300010000BE41063012345610 PARTNER 1 0 1
63100010001OL44483FW SCTOFBIONLO001010001001PARTNER 1 0 063100010001OL44483FW SCTOFBIONLO001010001001PARTNER 1 0 0
72100020000OL4414AC8BOVSOVSOVERS00000000030444501101110015000002010237 11011113501 072100020000OL4414AC8BOVSOVSOVERS00000000030444501101140015000002010237 11011413501 0
82200020000 BBRUBEBB 1 082200020000 BBRUBEBB 1 0
92300020000BE61310126985517 PARTNER 2 0 192300020000BE61310126985517 PARTNER 2 0 1
103100020001OL4414AC8BOVSOVSOVERS001500001001PARTNER 2 1 0103100020001OL4414AC8BOVSOVSOVERS001500001001PARTNER 2 1 0
113200020001MOLENSTRAAT 60 9340 LEDE 0 0113200020001MOLENSTRAAT 60 9340 LEDE 0 0
122100030000AFECA0CVA IKLINNINNIG1000000000479040110111313410000 KBC-INVESTERINGSKREDIET 737-6543210-21 11011113510 0122100030000AFECA0CVA IKLINNINNIG1000000000479040110114313410000 KBC-INVESTERINGSKREDIET 737-6543210-21 11011413510 0
132100030001AFECA0CVA IKLINNINNIG1000000000419920110111813410660 11011113500 0132100030001AFECA0CVA IKLINNINNIG1000000000419920110114813410660 11011413500 0
142100030002AFECA0CVA IKLINNINNIG1000000000059120110111813410020 11011113510 0142100030002AFECA0CVA IKLINNINNIG1000000000059120110114813410020 11011413510 0
152100040000AFECA0CVA IKLINNINNIG1000000000479040110111313410000 KBC-INVESTERINGSKREDIET 737-6543210-21 11011113510 0152100040000AFECA0CVA IKLINNINNIG1000000000479040110114313410000 KBC-INVESTERINGSKREDIET 737-6543210-21 11011413510 0
162100040001AFECA0CVA IKLINNINNIG1000000000419920110111813410660 11011113500 0162100040001AFECA0CVA IKLINNINNIG1000000000419920110114813410660 11011413500 0
172100040002AFECA0CVA IKLINNINNIG1000000000059120110111813410020 11011113510 0172100040002AFECA0CVA IKLINNINNIG1000000000059120110114813410020 11011413510 0
182100050000AOGM00160BSCTOBOGOVER0000000000063740110111001500000TERUGGAVE 37232481 8400083296 . 11011113501 0182100050000AOGM00160BSCTOBOGOVER0000000000063740110114001500000TERUGGAVE 37232481 8400083296 . 11011413501 0
192200050000 362/363 KREDBEBB 1 0192200050000 362/363 KREDBEBB 1 0
202300050000BE43730004200601 KBC VERZEKERINGEN NV 0 1202300050000BE43730004200601 KBC VERZEKERINGEN NV 0 1
213100050001AOGM00160BSCTOBOGOVER001500001001KBC VERZEKERINGEN NV 1 0213100050001AOGM00160BSCTOBOGOVER001500001001KBC VERZEKERINGEN NV 1 0
223200050001VAN OVERSTRAETENPLEIN 2 3000 LEUVEN 0 0223200050001VAN OVERSTRAETENPLEIN 2 3000 LEUVEN 0 0
238135BE44734024486445 EUR0000000013527810110111 0238135BE44734024486445 EUR0000000013527810110114 0
249 000022000000001393080000000003108190 2249 000022000000001393080000000003108190 2
2525
=== added directory 'l10n_be_coda/tests'
=== added file 'l10n_be_coda/tests/__init__.py'
--- l10n_be_coda/tests/__init__.py 1970-01-01 00:00:00 +0000
+++ l10n_be_coda/tests/__init__.py 2014-04-02 04:28:41 +0000
@@ -0,0 +1,4 @@
1from . import test_import_bank_statement
2checks = [
3 test_import_bank_statement
4]
05
=== added file 'l10n_be_coda/tests/test_import_bank_statement.py'
--- l10n_be_coda/tests/test_import_bank_statement.py 1970-01-01 00:00:00 +0000
+++ l10n_be_coda/tests/test_import_bank_statement.py 2014-04-02 04:28:41 +0000
@@ -0,0 +1,39 @@
1from openerp.tests.common import TransactionCase
2from openerp.modules.module import get_module_resource
3
4class TestCodaFile(TransactionCase):
5 """Tests for import bank statement coda file format (account.bank.statement.import)
6 """
7
8 def setUp(self):
9 super(TestCodaFile, self).setUp()
10 self.statement_import_model = self.registry('account.bank.statement.import')
11 self.bank_statement_model = self.registry('account.bank.statement')
12
13 def test_coda_file_import(self):
14 cr, uid = self.cr, self.uid
15 bank_temp_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'account', 'conf_bnk')
16 partner_id_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'main_partner')
17 company_id_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'main_company')
18 self.bank_temp_id = bank_temp_ref and bank_temp_ref[1] or False
19 self.partner_id = partner_id_ref and partner_id_ref[1] or False
20 self.company_id = company_id_ref and company_id_ref[1] or False
21 coda_file_path = get_module_resource('l10n_be_coda', 'test_coda_file', 'Ontvangen_CODA.2013-01-11-18.59.15.txt')
22 coda_file = open(coda_file_path, 'rb').read().encode('base64')
23 bank_account_id = self.registry('res.partner.bank').create(cr, uid, dict(
24 state = 'bank',
25 acc_number = 'BE33737018595246',
26 bank_name = 'Reserve',
27 partner_id = self.partner_id,
28 company_id = self.company_id
29 ))
30 bank_statement_id = self.statement_import_model.create(cr, uid, dict(
31 file_type = 'coda',
32 data_file = coda_file,
33 account_id = self.bank_temp_id
34 ))
35 self.statement_import_model.parse_file(cr, uid, [bank_statement_id])
36 statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '135')])[0]
37 bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id)
38 self.assertEquals(bank_st_record.balance_start, 11812.70)
39 self.assertEquals(bank_st_record.balance_end_real, 13527.81)
040
=== modified file 'l10n_be_coda/wizard/account_coda_import.py'
--- l10n_be_coda/wizard/account_coda_import.py 2013-10-27 12:31:04 +0000
+++ l10n_be_coda/wizard/account_coda_import.py 2014-04-02 04:28:41 +0000
@@ -30,44 +30,21 @@
3030
31_logger = logging.getLogger(__name__)31_logger = logging.getLogger(__name__)
3232
33class account_coda_import(osv.osv_memory):33from openerp.addons.account import account_bank_statement_import as coda_ibs
34 _name = 'account.coda.import'34
35coda_ibs._IMPORT_FILE_TYPE.append(('coda', 'CODA'))
36
37class account_bank_statement_import(osv.TransientModel):
38 _inherit = "account.bank.statement.import"
35 _description = 'Import CODA File'39 _description = 'Import CODA File'
36 _columns = {40 _columns = {
37 'coda_data': fields.binary('CODA File', required=True),41 'file_type': fields.selection(coda_ibs._IMPORT_FILE_TYPE, 'File Type'),
38 'coda_fname': fields.char('CODA Filename', size=128, required=True),
39 'note': fields.text('Log'),42 'note': fields.text('Log'),
40 'temporary_account_id': fields.many2one('account.account', 'Temporary Account', domain="[('type','!=','view')]", help="It acts as a temporary account for general amount", required=True),43 }
41 }44
4245 def process_coda(self, cr, uid, codafile, journal_id=False, account_id=False, context=None):
43 def _get_default_tmp_account(self, cr, uid, context):
44 tmp_accounts = self.pool.get('account.account').search(cr, uid, [('code', '=', '490000')])
45 if tmp_accounts and len(tmp_accounts) > 0:
46 tmp_account_id = tmp_accounts[0]
47 else:
48 tmp_account_id = False
49 return tmp_account_id
50
51 _defaults = {
52 'coda_fname': lambda *a: '',
53 'temporary_account_id': _get_default_tmp_account,
54 }
55
56 def coda_parsing(self, cr, uid, ids, context=None, batch=False, codafile=None, codafilename=None):
57 if context is None:46 if context is None:
58 context = {}47 context = {}
59 if batch:
60 codafile = str(codafile)
61 codafilename = codafilename
62 else:
63 data = self.browse(cr, uid, ids)[0]
64 try:
65 codafile = data.coda_data
66 codafilename = data.coda_fname
67 temporaryaccount = data.temporary_account_id.id
68 except:
69 raise osv.except_osv(_('Error'), _('Wizard in incorrect state. Please hit the Cancel button'))
70 return {}
71 recordlist = unicode(base64.decodestring(codafile), 'windows-1252', 'strict').split('\n')48 recordlist = unicode(base64.decodestring(codafile), 'windows-1252', 'strict').split('\n')
72 statements = []49 statements = []
73 for line in recordlist:50 for line in recordlist:
@@ -254,6 +231,7 @@
254 statement['balance_end_real'] = statement['balance_start'] + statement['balancePlus'] - statement['balanceMin']231 statement['balance_end_real'] = statement['balance_start'] + statement['balancePlus'] - statement['balanceMin']
255 for i, statement in enumerate(statements):232 for i, statement in enumerate(statements):
256 statement['coda_note'] = ''233 statement['coda_note'] = ''
234 statement_line = []
257 balance_start_check_date = (len(statement['lines']) > 0 and statement['lines'][0]['entryDate']) or statement['date']235 balance_start_check_date = (len(statement['lines']) > 0 and statement['lines'][0]['entryDate']) or statement['date']
258 cr.execute('SELECT balance_end_real \236 cr.execute('SELECT balance_end_real \
259 FROM account_bank_statement \237 FROM account_bank_statement \
@@ -278,7 +256,6 @@
278 'balance_start': statement['balance_start'],256 'balance_start': statement['balance_start'],
279 'balance_end_real': statement['balance_end_real'],257 'balance_end_real': statement['balance_end_real'],
280 }258 }
281 statement['id'] = self.pool.get('account.bank.statement').create(cr, uid, data, context=context)
282 for line in statement['lines']:259 for line in statement['lines']:
283 if line['type'] == 'information':260 if line['type'] == 'information':
284 statement['coda_note'] = "\n".join([statement['coda_note'], line['type'].title() + ' with Ref. ' + str(line['ref']), 'Date: ' + str(line['entryDate']), 'Communication: ' + line['communication'], ''])261 statement['coda_note'] = "\n".join([statement['coda_note'], line['type'].title() + ' with Ref. ' + str(line['ref']), 'Date: ' + str(line['entryDate']), 'Communication: ' + line['communication'], ''])
@@ -372,12 +349,12 @@
372 if partner.supplier:349 if partner.supplier:
373 line['transaction_type'] = 'supplier'350 line['transaction_type'] = 'supplier'
374 if not partner and not invoice:351 if not partner and not invoice:
375 line['account'] = temporaryaccount352 line['account'] = account_id
376 if 'communication' in line and line['communication'] != '':353 if 'communication' in line and line['communication'] != '':
377 note.append(_('Communication') + ': ' + line['communication'])354 note.append(_('Communication') + ': ' + line['communication'])
378 if 'voucher_id' not in line:355 if 'voucher_id' not in line:
379 line['voucher_id'] = None356 line['voucher_id'] = None
380 data = {357 line_data = {
381 'name': line['name'],358 'name': line['name'],
382 'note': "\n".join(note),359 'note': "\n".join(note),
383 'date': line['entryDate'],360 'date': line['entryDate'],
@@ -385,28 +362,16 @@
385 'type': line['transaction_type'],362 'type': line['transaction_type'],
386 'partner_id': partner_id,363 'partner_id': partner_id,
387 'account_id': line['account'],364 'account_id': line['account'],
388 'statement_id': statement['id'],
389 'ref': line['ref'],365 'ref': line['ref'],
390 'sequence': line['sequence'],366 'sequence': line['sequence'],
391 'voucher_id': line['voucher_id'],367 'voucher_id': line['voucher_id'],
392 'coda_account_number': line['counterpartyNumber'],368 'coda_account_number': line['counterpartyNumber'],
393 }369 }
394 self.pool.get('account.bank.statement.line').create(cr, uid, data, context=context)370 statement_line.append((0, 0, line_data))
395 if statement['coda_note'] != '':371 if statement['coda_note'] != '':
396 self.pool.get('account.bank.statement').write(cr, uid, [statement['id']], {'coda_note': statement['coda_note']}, context=context)372 data.update({'coda_note': statement['coda_note']})
397 model, action_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'action_bank_statement_tree')373 data.update({'journal_id': journal_id, 'line_ids' : statement_line})
398 action = self.pool[model].browse(cr, uid, action_id, context=context)374 return data
399 return {
400 'name': action.name,
401 'view_type': action.view_type,
402 'view_mode': action.view_mode,
403 'res_model': action.res_model,
404 'domain': action.domain,
405 'context': action.context,
406 'type': 'ir.actions.act_window',
407 'search_view_id': action.search_view_id.id,
408 'views': [(v.view_id.id, v.view_mode) for v in action.view_ids]
409 }
410375
411376
412def rmspaces(s):377def rmspaces(s):

Subscribers

People subscribed via source and target branches

to all changes: