Merge lp:~acsone-openerp/banking-addons/bank-statement-reconcile-70 into lp:banking-addons/bank-statement-reconcile-70

Proposed by Laurent Mignon (Acsone)
Status: Merged
Merged at revision: 99
Proposed branch: lp:~acsone-openerp/banking-addons/bank-statement-reconcile-70
Merge into: lp:banking-addons/bank-statement-reconcile-70
Diff against target: 514 lines (+379/-51)
10 files modified
account_statement_bankaccount_completion/__init__.py (+21/-0)
account_statement_bankaccount_completion/__openerp__.py (+49/-0)
account_statement_bankaccount_completion/data.xml (+12/-0)
account_statement_bankaccount_completion/statement.py (+96/-0)
account_statement_bankaccount_completion/tests/__init__.py (+27/-0)
account_statement_bankaccount_completion/tests/test_bankaccount_completion.py (+91/-0)
account_statement_base_completion/statement.py (+77/-0)
account_statement_base_import/statement.py (+0/-49)
account_statement_ext/statement.py (+5/-1)
account_statement_transactionid_completion/statement.py (+1/-1)
To merge this branch: bzr merge lp:~acsone-openerp/banking-addons/bank-statement-reconcile-70
Reviewer Review Type Date Requested Status
Stéphane Bidoul (Acsone) (community) Approve
Joël Grand-Guillaume @ camptocamp code review, no tests Approve
Guewen Baconnier @ Camptocamp code review, no test Approve
Review via email: mp+185047@code.launchpad.net

Description of the change

Fixes lp:1223834 in case of insert. Batch updates remains error prone. It would be safer to call the update method from the orm for records updating 'complex' fields.

A new completion rule based on the bank account number is also provided by the proposal.

About modules dependencies. The module 'account_statement_base_import' depends of 'account_statement_base_completion' but the file statement.py of 'account_statement_base_completion' at line 513 call the method _update_line defined in 'account_statement_base_import'. Since the 'AccountStatementLine' is defined in both addons, I've the feeling that we can merge the two overrides in 'account_statement_base_completion'. What's your opinion?

Regards,

lmi

To post a comment you must log in.
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

In manifest, author should be ACSONE SA/NV.

I also reach the conclusion that AccountStatementLine can be moved from account_statement_base_import to account_statement_base_completion, but this should be confirmed by someone more familiar with the project.

On a related note, the dependency of account_statement_base_import depends on account_statement_ext is redundant as it is pulled indirectly through account_statement_base_completion.

In the _insert_line fix, I suggest renaming _get_values to something a bit more explicit such as _serialize_sparse_fields, and possiblity working on a copy of statement_store to avoid side-effects.

Otherwise LGTM.

Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

Maybe add a TODO in _update_lines to mention the potential pitfall with serializable fields.

110. By Laurent Mignon (Acsone)

set 'ACSONE SA/NV' as author in the manifest

111. By Laurent Mignon (Acsone)

rename _get_values method in _serialize_sparse_fields, comment the method and work on a copy of statement_store to avoid side-effects

112. By Laurent Mignon (Acsone)

add a TODO in _update_lines to mention the potential pitfall with serializable fields

Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

Hi Stéphane,

Thanks for the review. The code has been modified according to your remarks.

lmi

113. By Laurent Mignon (Acsone)

pep8

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

> I also reach the conclusion that AccountStatementLine can be moved from
> account_statement_base_import to account_statement_base_completion, but this
> should be confirmed by someone more familiar with the project.>

Agree with that.

Seems good to me (with tests, yeah), some little things:

l.65
I would replace
    if st_line['partner_acc_number'] == False:
by
    if not st_line['partner_acc_number']:

l.96 s/Nomal/Normal/

l.137 empty line before the docstring to remove

l.175 it would probably be useful for the user to give the account number in the error message

l.196ff s/Additionnal/Additional/

Thanks!

114. By Laurent Mignon (Acsone)

fixes spelling, formatting and comparison according to the code review

115. By Laurent Mignon (Acsone)

relocate methods defined for AccountStatementLine in account_statement_base_import to account_statement_base_completion

Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

Hi Guewen,

Thanks for the review. I've integrated your remarks in the code. In the same time, the changes made to solve the dependecy problem fixes the lp:1216886 issue.

A last remark, if you run the test of 'account_statement_bankaccount_completion' with the module 'account_statement_base_import' installed in the same db, it fails (missing required value'import_type'). I don't know if it's really an issue.

Regards,

lmi

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Thanks for the changes!

That's a common issue with tests, when a module adds a NOT NULL constraint on a column, other modules tests do not fill this required field and fails. But I don't think that's something we can avoid.
I think that the most important is to have success results when the module is installed alone.

Looks good to me

review: Approve (code review, no test)
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Thanks for the contribs ! It look good to me.

review: Approve (code review, no tests)
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_statement_bankaccount_completion'
2=== added file 'account_statement_bankaccount_completion/__init__.py'
3--- account_statement_bankaccount_completion/__init__.py 1970-01-01 00:00:00 +0000
4+++ account_statement_bankaccount_completion/__init__.py 2013-09-12 09:05:59 +0000
5@@ -0,0 +1,21 @@
6+# -*- coding: utf-8 -*-
7+#
8+#
9+# Author: Laurent Mignon
10+# Copyright 2013 'ACSONE SA/NV'
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU Affero General Public License as
14+# published by the Free Software Foundation, either version 3 of the
15+# License, or (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU Affero General Public License for more details.
21+#
22+# You should have received a copy of the GNU Affero General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25+#
26+import statement
27
28=== added file 'account_statement_bankaccount_completion/__openerp__.py'
29--- account_statement_bankaccount_completion/__openerp__.py 1970-01-01 00:00:00 +0000
30+++ account_statement_bankaccount_completion/__openerp__.py 2013-09-12 09:05:59 +0000
31@@ -0,0 +1,49 @@
32+# -*- coding: utf-8 -*-
33+#
34+#
35+# Author: Laurent Mignon
36+# Copyright 2013 'ACSONE SA/NV'
37+#
38+# This program is free software: you can redistribute it and/or modify
39+# it under the terms of the GNU Affero General Public License as
40+# published by the Free Software Foundation, either version 3 of the
41+# License, or (at your option) any later version.
42+#
43+# This program is distributed in the hope that it will be useful,
44+# but WITHOUT ANY WARRANTY; without even the implied warranty of
45+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46+# GNU Affero General Public License for more details.
47+#
48+# You should have received a copy of the GNU Affero General Public License
49+# along with this program. If not, see <http://www.gnu.org/licenses/>.
50+#
51+#
52+
53+{'name': "Bank statement completion from bank account number",
54+ 'version': '1.0',
55+ 'author': 'ACSONE SA/NV',
56+ 'maintainer': 'ACSONE SA/NV',
57+ 'category': 'Finance',
58+ 'complexity': 'normal',
59+ 'depends': [
60+ 'account_statement_base_completion',
61+ ],
62+ 'description': """
63+ Add a completion method based on the partner bank account number provided by the bank/office.
64+
65+ Completion will look in the partner with that bank account number to match the partner,
66+ then it will fill in the bank statement line with it to ease the reconciliation.
67+
68+ """,
69+ 'website': 'http://www.acsone.eu',
70+ 'init_xml': [],
71+ 'update_xml': [
72+ "data.xml",
73+ ],
74+ 'demo_xml': [],
75+ 'test': [],
76+ 'installable': True,
77+ 'images': [],
78+ 'auto_install': True,
79+ 'license': 'AGPL-3',
80+ }
81
82=== added file 'account_statement_bankaccount_completion/data.xml'
83--- account_statement_bankaccount_completion/data.xml 1970-01-01 00:00:00 +0000
84+++ account_statement_bankaccount_completion/data.xml 2013-09-12 09:05:59 +0000
85@@ -0,0 +1,12 @@
86+<?xml version="1.0" encoding="utf-8"?>
87+<openerp>
88+<data noupdate="1">
89+
90+ <record id="bank_statement_completion_rule_10" model="account.statement.completion.rule">
91+ <field name="name">Match from bank account number (Nomal or IBAN))</field>
92+ <field name="sequence">10</field>
93+ <field name="function_to_call">get_from_bank_account</field>
94+ </record>
95+
96+</data>
97+</openerp>
98
99=== added file 'account_statement_bankaccount_completion/statement.py'
100--- account_statement_bankaccount_completion/statement.py 1970-01-01 00:00:00 +0000
101+++ account_statement_bankaccount_completion/statement.py 2013-09-12 09:05:59 +0000
102@@ -0,0 +1,96 @@
103+# -*- coding: utf-8 -*-
104+#
105+#
106+# Author: Laurent Mignon
107+# Copyright 2013 'ACSONE SA/NV'
108+#
109+# This program is free software: you can redistribute it and/or modify
110+# it under the terms of the GNU Affero General Public License as
111+# published by the Free Software Foundation, either version 3 of the
112+# License, or (at your option) any later version.
113+#
114+# This program is distributed in the hope that it will be useful,
115+# but WITHOUT ANY WARRANTY; without even the implied warranty of
116+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
117+# GNU Affero General Public License for more details.
118+#
119+# You should have received a copy of the GNU Affero General Public License
120+# along with this program. If not, see <http://www.gnu.org/licenses/>.
121+#
122+#
123+
124+
125+from openerp.tools.translate import _
126+from openerp.osv.orm import Model
127+from openerp.osv import fields
128+from openerp.addons.account_statement_base_completion.statement import ErrorTooManyPartner
129+
130+
131+class AccountStatementCompletionRule(Model):
132+ """Add a rule based on transaction ID"""
133+
134+ _inherit = "account.statement.completion.rule"
135+
136+ def _get_functions(self, cr, uid, context=None):
137+ res = super(AccountStatementCompletionRule, self)._get_functions(
138+ cr, uid, context=context)
139+ res.append(('get_from_bank_account',
140+ 'From bank account number (Normal or IBAN)'))
141+ return res
142+
143+ _columns = {
144+ 'function_to_call': fields.selection(_get_functions, 'Method'),
145+ }
146+
147+ def get_from_bank_account(self, cr, uid, st_line, context=None):
148+ """
149+ Match the partner based on the partner account number field
150+ Then, call the generic st_line method to complete other values.
151+ :param dict st_line: read of the concerned account.bank.statement.line
152+ :return:
153+ A dict of value that can be passed directly to the write method of
154+ the statement line or {}
155+ {'partner_id': value,
156+ 'account_id' : value,
157+ ...}
158+ """
159+ partner_acc_number = st_line['partner_acc_number']
160+ if not partner_acc_number:
161+ return {}
162+ st_obj = self.pool.get('account.bank.statement.line')
163+ res = {}
164+ res_bank_obj = self.pool.get('res.partner.bank')
165+ ids = res_bank_obj.search(cr,
166+ uid,
167+ [('acc_number', '=', partner_acc_number)],
168+ context=context)
169+ if len(ids) > 1:
170+ raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by more than '
171+ 'one partner for account number "%s".') % (st_line['name'], st_line['ref'], partner_acc_number))
172+ if len(ids) == 1:
173+ partner = res_bank_obj.browse(cr, uid, ids[0], context=context).partner_id
174+ res['partner_id'] = partner.id
175+ st_vals = st_obj.get_values_for_line(cr,
176+ uid,
177+ profile_id=st_line['profile_id'],
178+ master_account_id=st_line['master_account_id'],
179+ partner_id=res.get('partner_id', False),
180+ line_type=st_line['type'],
181+ amount=st_line['amount'] if st_line['amount'] else 0.0,
182+ context=context)
183+ res.update(st_vals)
184+ return res
185+
186+
187+class AccountStatementLine(Model):
188+ _inherit = "account.bank.statement.line"
189+
190+ _columns = {
191+ # 'additional_bank_fields' : fields.serialized('Additional infos from bank', help="Used by completion and import system."),
192+ 'partner_acc_number': fields.sparse(
193+ type='char',
194+ string='Account Number',
195+ size=64,
196+ serialization_field='additionnal_bank_fields',
197+ help="Account number of the partner"),
198+ }
199
200=== added directory 'account_statement_bankaccount_completion/tests'
201=== added file 'account_statement_bankaccount_completion/tests/__init__.py'
202--- account_statement_bankaccount_completion/tests/__init__.py 1970-01-01 00:00:00 +0000
203+++ account_statement_bankaccount_completion/tests/__init__.py 2013-09-12 09:05:59 +0000
204@@ -0,0 +1,27 @@
205+# -*- coding: utf-8 -*-
206+#
207+#
208+# Authors: Laurent Mignon
209+# Copyright (c) 2013 Acsone SA/NV (http://www.acsone.eu)
210+# All Rights Reserved
211+#
212+# This program is free software: you can redistribute it and/or modify
213+# it under the terms of the GNU Affero General Public License as
214+# published by the Free Software Foundation, either version 3 of the
215+# License, or (at your option) any later version.
216+#
217+# This program is distributed in the hope that it will be useful,
218+# but WITHOUT ANY WARRANTY; without even the implied warranty of
219+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
220+# GNU Affero General Public License for more details.
221+#
222+# You should have received a copy of the GNU Affero General Public License
223+# along with this program. If not, see <http://www.gnu.org/licenses/>.
224+#
225+#
226+
227+from . import test_bankaccount_completion
228+
229+checks = [
230+ test_bankaccount_completion
231+]
232
233=== added file 'account_statement_bankaccount_completion/tests/test_bankaccount_completion.py'
234--- account_statement_bankaccount_completion/tests/test_bankaccount_completion.py 1970-01-01 00:00:00 +0000
235+++ account_statement_bankaccount_completion/tests/test_bankaccount_completion.py 2013-09-12 09:05:59 +0000
236@@ -0,0 +1,91 @@
237+# -*- coding: utf-8 -*-
238+#
239+#
240+# Authors: Laurent Mignon
241+# Copyright (c) 2013 Acsone SA/NV (http://www.acsone.eu)
242+# All Rights Reserved
243+#
244+# This program is free software: you can redistribute it and/or modify
245+# it under the terms of the GNU Affero General Public License as
246+# published by the Free Software Foundation, either version 3 of the
247+# License, or (at your option) any later version.
248+#
249+# This program is distributed in the hope that it will be useful,
250+# but WITHOUT ANY WARRANTY; without even the implied warranty of
251+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
252+# GNU Affero General Public License for more details.
253+#
254+# You should have received a copy of the GNU Affero General Public License
255+# along with this program. If not, see <http://www.gnu.org/licenses/>.
256+#
257+#
258+from openerp.tests import common
259+import time
260+
261+ACC_NUMBER = "BE38733040385372"
262+
263+
264+class bankaccount_completion(common.TransactionCase):
265+
266+ def prepare(self):
267+ self.company_a = self.browse_ref('base.main_company')
268+ self.profile_obj = self.registry("account.statement.profile")
269+ self.account_bank_statement_obj = self.registry("account.bank.statement")
270+ self.account_bank_statement_line_obj = self.registry("account.bank.statement.line")
271+ self.completion_rule_id = self.ref('account_statement_bankaccount_completion.bank_statement_completion_rule_10')
272+ self.journal_id = self.registry("ir.model.data").get_object_reference(self.cr, self. uid, "account", "bank_journal")[1]
273+ self.partner_id = self.ref('base.main_partner')
274+ # Create the profile
275+ self.account_id = self.registry("ir.model.data").get_object_reference(self.cr, self.uid, "account", "a_recv")[1]
276+ self.journal_id = self.registry("ir.model.data").get_object_reference(self.cr, self. uid, "account", "bank_journal")[1]
277+ self.profile_id = self.profile_obj.create(self.cr, self.uid, {
278+ "name": "TEST",
279+ "commission_account_id": self.account_id,
280+ "journal_id": self.journal_id,
281+ "rule_ids": [(6, 0, [self.completion_rule_id])]})
282+ # Create the completion rule
283+
284+ # Create a bank statement
285+ self.statement_id = self.account_bank_statement_obj.create(self.cr, self.uid, {
286+ "balance_end_real": 0.0,
287+ "balance_start": 0.0,
288+ "date": time.strftime('%Y-%m-%d'),
289+ "journal_id": self.journal_id,
290+ "profile_id": self.profile_id
291+
292+ })
293+
294+ # Create bank a statement line
295+ self.statement_line_id = self.account_bank_statement_line_obj.create(self.cr, self.uid, {
296+ 'amount': 1000.0,
297+ 'name': 'EXT001',
298+ 'ref': 'My ref',
299+ 'statement_id': self.statement_id,
300+ 'partner_acc_number': ACC_NUMBER
301+ })
302+
303+ # Add a bank account number to the partner
304+ res_bank_obj = self.registry('res.partner.bank')
305+ res_bank_obj.create(self.cr, self.uid, {
306+ "state": "bank",
307+ "company_id": self.company_a.id,
308+ "partner_id": self.partner_id,
309+ "acc_number": ACC_NUMBER,
310+ "footer": True,
311+ "bank_name": "Reserve"
312+ })
313+
314+ def test_00(self):
315+ """Test complete partner_id from bank account number
316+
317+ Test the automatic completion of the partner_id based on the account number associated to the
318+ statement line
319+ """
320+ self.prepare()
321+ statement_line = self.account_bank_statement_line_obj.browse(self.cr, self.uid, self.statement_line_id)
322+ # before import, the
323+ self.assertFalse(statement_line.partner_id, "Partner_id must be blank before completion")
324+ statement_obj = self.account_bank_statement_obj.browse(self.cr, self.uid, self.statement_id)
325+ statement_obj.button_auto_completion()
326+ statement_line = self.account_bank_statement_line_obj.browse(self.cr, self.uid, self.statement_line_id)
327+ self.assertEquals(self.partner_id, statement_line.partner_id['id'], "Missing expected partner id after completion")
328
329=== modified file 'account_statement_base_completion/statement.py'
330--- account_statement_base_completion/statement.py 2013-04-30 09:51:39 +0000
331+++ account_statement_base_completion/statement.py 2013-09-12 09:05:59 +0000
332@@ -22,6 +22,9 @@
333 import traceback
334 import sys
335 import logging
336+import simplejson
337+
338+import psycopg2
339
340 from collections import defaultdict
341 import re
342@@ -425,6 +428,80 @@
343 return vals
344 return {}
345
346+ def _get_available_columns(self, statement_store, include_serializable=False):
347+ """Return writeable by SQL columns"""
348+ statement_line_obj = self.pool['account.bank.statement.line']
349+ model_cols = statement_line_obj._columns
350+ avail = [k for k, col in model_cols.iteritems() if not hasattr(col, '_fnct')]
351+ keys = [k for k in statement_store[0].keys() if k in avail]
352+ # add sparse fields..
353+ if include_serializable:
354+ for k, col in model_cols.iteritems():
355+ if k in statement_store[0].keys() and \
356+ isinstance(col, fields.sparse) and \
357+ col.serialization_field not in keys and \
358+ col._type == 'char':
359+ keys.append(col.serialization_field)
360+ keys.sort()
361+ return keys
362+
363+ def _serialize_sparse_fields(self, cols, statement_store):
364+ """ Serialize sparse fields values in the target serialized field
365+ Return a copy of statement_store
366+ """
367+ statement_line_obj = self.pool['account.bank.statement.line']
368+ model_cols = statement_line_obj._columns
369+ sparse_fields = dict([(k , col) for k, col in model_cols.iteritems() if isinstance(col, fields.sparse) and col._type == 'char'])
370+ values = []
371+ for statement in statement_store:
372+ to_json_k = set()
373+ st_copy = statement.copy()
374+ for k, col in sparse_fields.iteritems():
375+ if k in st_copy:
376+ to_json_k.add(col.serialization_field)
377+ serialized = st_copy.setdefault(col.serialization_field, {})
378+ serialized[k] = st_copy[k]
379+ for k in to_json_k:
380+ st_copy[k] = simplejson.dumps(st_copy[k])
381+ values.append(st_copy)
382+ return values
383+
384+
385+ def _insert_lines(self, cr, uid, statement_store, context=None):
386+ """ Do raw insert into database because ORM is awfully slow
387+ when doing batch write. It is a shame that batch function
388+ does not exist"""
389+ statement_line_obj = self.pool['account.bank.statement.line']
390+ statement_line_obj.check_access_rule(cr, uid, [], 'create')
391+ statement_line_obj.check_access_rights(cr, uid, 'create', raise_exception=True)
392+ cols = self._get_available_columns(statement_store, include_serializable=True)
393+ tmp_vals = (', '.join(cols), ', '.join(['%%(%s)s' % i for i in cols]))
394+ sql = "INSERT INTO account_bank_statement_line (%s) VALUES (%s);" % tmp_vals
395+ try:
396+ cr.executemany(sql, tuple(self._serialize_sparse_fields(cols, statement_store)))
397+ except psycopg2.Error as sql_err:
398+ cr.rollback()
399+ raise osv.except_osv(_("ORM bypass error"),
400+ sql_err.pgerror)
401+
402+ def _update_line(self, cr, uid, vals, context=None):
403+ """ Do raw update into database because ORM is awfully slow
404+ when cheking security.
405+ TODO / WARM: sparse fields are skipped by the method. IOW, if your
406+ completion rule update an sparse field, the updated value will never
407+ be stored in the database. It would be safer to call the update method
408+ from the ORM for records updating this kind of fields.
409+ """
410+ cols = self._get_available_columns([vals])
411+ tmp_vals = (', '.join(['%s = %%(%s)s' % (i, i) for i in cols]))
412+ sql = "UPDATE account_bank_statement_line SET %s where id = %%(id)s;" % tmp_vals
413+ try:
414+ cr.execute(sql, vals)
415+ except psycopg2.Error as sql_err:
416+ cr.rollback()
417+ raise osv.except_osv(_("ORM bypass error"),
418+ sql_err.pgerror)
419+
420
421 class AccountBankSatement(orm.Model):
422 """
423
424=== modified file 'account_statement_base_import/statement.py'
425--- account_statement_base_import/statement.py 2013-05-03 19:57:26 +0000
426+++ account_statement_base_import/statement.py 2013-09-12 09:05:59 +0000
427@@ -21,8 +21,6 @@
428 import sys
429 import traceback
430
431-import psycopg2
432-
433 from openerp.tools.translate import _
434 import datetime
435 from openerp.osv.orm import Model
436@@ -216,50 +214,3 @@
437 raise osv.except_osv(_("Statement import error"),
438 _("The statement cannot be created: %s") % st)
439 return statement_id
440-
441-
442-class AccountStatementLine(Model):
443- """
444- Add sparse field on the statement line to allow to store all the
445- bank infos that are given by an office.
446- """
447- _inherit = "account.bank.statement.line"
448-
449- def _get_available_columns(self, statement_store):
450- """Return writeable by SQL columns"""
451- statement_line_obj = self.pool['account.bank.statement.line']
452- model_cols = statement_line_obj._columns
453- avail = [k for k, col in model_cols.iteritems() if not hasattr(col, '_fnct')]
454- keys = [k for k in statement_store[0].keys() if k in avail]
455- keys.sort()
456- return keys
457-
458- def _insert_lines(self, cr, uid, statement_store, context=None):
459- """ Do raw insert into database because ORM is awfully slow
460- when doing batch write. It is a shame that batch function
461- does not exist"""
462- statement_line_obj = self.pool['account.bank.statement.line']
463- statement_line_obj.check_access_rule(cr, uid, [], 'create')
464- statement_line_obj.check_access_rights(cr, uid, 'create', raise_exception=True)
465- cols = self._get_available_columns(statement_store)
466- tmp_vals = (', '.join(cols), ', '.join(['%%(%s)s' % i for i in cols]))
467- sql = "INSERT INTO account_bank_statement_line (%s) VALUES (%s);" % tmp_vals
468- try:
469- cr.executemany(sql, tuple(statement_store))
470- except psycopg2.Error as sql_err:
471- cr.rollback()
472- raise osv.except_osv(_("ORM bypass error"),
473- sql_err.pgerror)
474-
475- def _update_line(self, cr, uid, vals, context=None):
476- """ Do raw update into database because ORM is awfully slow
477- when cheking security."""
478- cols = self._get_available_columns([vals])
479- tmp_vals = (', '.join(['%s = %%(%s)s' % (i, i) for i in cols]))
480- sql = "UPDATE account_bank_statement_line SET %s where id = %%(id)s;" % tmp_vals
481- try:
482- cr.execute(sql, vals)
483- except psycopg2.Error as sql_err:
484- cr.rollback()
485- raise osv.except_osv(_("ORM bypass error"),
486- sql_err.pgerror)
487
488=== modified file 'account_statement_ext/statement.py'
489--- account_statement_ext/statement.py 2013-05-24 09:38:35 +0000
490+++ account_statement_ext/statement.py 2013-09-12 09:05:59 +0000
491@@ -553,7 +553,11 @@
492 if context is None:
493 context = {}
494 date = context.get('date')
495- periods = self.pool.get('account.period').find(cr, uid, dt=date)
496+ try:
497+ periods = self.pool.get('account.period').find(cr, uid, dt=date)
498+ except osv.except_osv:
499+ # if no period defined, we are certainly at installation time
500+ return False
501 return periods and periods[0] or False
502
503 def _get_default_account(self, cr, uid, context=None):
504
505=== modified file 'account_statement_transactionid_completion/statement.py'
506--- account_statement_transactionid_completion/statement.py 2013-04-25 11:30:23 +0000
507+++ account_statement_transactionid_completion/statement.py 2013-09-12 09:05:59 +0000
508@@ -90,5 +90,5 @@
509 string='Transaction ID',
510 size=128,
511 serialization_field='additionnal_bank_fields',
512- help="Transction id from the financial institute"),
513+ help="Transaction id from the financial institute"),
514 }

Subscribers

People subscribed via source and target branches