Merge lp:~camptocamp/banking-addons/bank-statement-reconcile-7.0-fix-1313689 into lp:banking-addons/bank-statement-reconcile-70

Proposed by Yannick Vaucher @ Camptocamp
Status: Merged
Merged at revision: 147
Proposed branch: lp:~camptocamp/banking-addons/bank-statement-reconcile-7.0-fix-1313689
Merge into: lp:banking-addons/bank-statement-reconcile-70
Diff against target: 108 lines (+25/-17)
2 files modified
account_statement_base_completion/statement.py (+23/-0)
account_statement_base_import/statement.py (+2/-17)
To merge this branch: bzr merge lp:~camptocamp/banking-addons/bank-statement-reconcile-7.0-fix-1313689
Reviewer Review Type Date Requested Status
Laurent Mignon (Acsone) (community) code veview, no tests Approve
Joël Grand-Guillaume @ camptocamp code review, no tests Approve
Banking Addons Core Editors Pending
Review via email: mp+218575@code.launchpad.net

Description of the change

Few cleaning to complete fix for 1313689

 * The _insert_lines and _update_line method in *_base_completion/statement.py calls the symbol_f method to prorperly initiate the default value (e.g. integer default null value should be Null not False).

 * The mechanism that allow to have a null account_id in bank statement line has been move in *_base_completion, instead of *_base_import.

To post a comment you must log in.
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi Yannick,

Thanks for this merge !

LGTM,

Regards

review: Approve (code review, no tests)
Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

Hi Yannick,

Thanks for the contribs!

LGTM,

Regards

lmi

review: Approve (code veview, no tests)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_statement_base_completion/statement.py'
2--- account_statement_base_completion/statement.py 2014-04-27 18:44:20 +0000
3+++ account_statement_base_completion/statement.py 2014-05-07 08:58:28 +0000
4@@ -397,6 +397,8 @@
5 "Auto-Completed",
6 help="When this checkbox is ticked, the auto-completion "
7 "process/button will ignore this line."),
8+ # Set account_id field as optional by removing required option.
9+ 'account_id': fields.many2one('account.account', 'Account'),
10 }
11
12 _defaults = {
13@@ -440,6 +442,25 @@
14 keys.sort()
15 return keys
16
17+ def _prepare_insert(self, statement, cols):
18+ """ Apply column formating to prepare data for SQL inserting
19+ Return a copy of statement
20+ """
21+ st_copy = statement
22+ for k, col in st_copy.iteritems():
23+ if k in cols:
24+ st_copy[k] = self._columns[k]._symbol_set[1](col)
25+ return st_copy
26+
27+ def _prepare_manyinsert(self, statement_store, cols):
28+ """ Apply column formating to prepare multiple SQL inserts
29+ Return a copy of statement_store
30+ """
31+ values = []
32+ for statement in statement_store:
33+ values.append(self._prepare_insert(statement, cols))
34+ return values
35+
36 def _serialize_sparse_fields(self, cols, statement_store):
37 """ Serialize sparse fields values in the target serialized field
38 Return a copy of statement_store
39@@ -469,6 +490,7 @@
40 statement_line_obj.check_access_rule(cr, uid, [], 'create')
41 statement_line_obj.check_access_rights(cr, uid, 'create', raise_exception=True)
42 cols = self._get_available_columns(statement_store, include_serializable=True)
43+ statement_store = self._prepare_manyinsert(statement_store, cols)
44 tmp_vals = (', '.join(cols), ', '.join(['%%(%s)s' % i for i in cols]))
45 sql = "INSERT INTO account_bank_statement_line (%s) VALUES (%s);" % tmp_vals
46 try:
47@@ -487,6 +509,7 @@
48 from the ORM for records updating this kind of fields.
49 """
50 cols = self._get_available_columns([vals])
51+ vals = self._prepare_insert(vals, cols)
52 tmp_vals = (', '.join(['%s = %%(%s)s' % (i, i) for i in cols]))
53 sql = "UPDATE account_bank_statement_line SET %s where id = %%(id)s;" % tmp_vals
54 try:
55
56=== modified file 'account_statement_base_import/statement.py'
57--- account_statement_base_import/statement.py 2014-04-28 15:07:53 +0000
58+++ account_statement_base_import/statement.py 2014-05-07 08:58:28 +0000
59@@ -95,7 +95,7 @@
60 return self.prepare_statement_lines_vals(*args, **kwargs)
61
62 def prepare_statement_lines_vals(
63- self, cr, uid, parser_vals, account_payable, account_receivable,
64+ self, cr, uid, parser_vals,
65 statement_id, context):
66 """
67 Hook to build the values of a line from the parser returned values. At
68@@ -104,8 +104,6 @@
69
70 :param dict of vals from parser for account.bank.statement.line (called by
71 parser.get_st_line_vals)
72- :param int/long account_payable: ID of the receivable account to use
73- :param int/long account_receivable: ID of the payable account to use
74 :param int/long statement_id: ID of the concerned account.bank.statement
75 :return: dict of vals that will be passed to create method of statement line.
76 """
77@@ -176,18 +174,13 @@
78 statement_vals,
79 context=context)
80
81- if prof.receivable_account_id:
82- account_receivable = account_payable = prof.receivable_account_id.id
83- else:
84- account_receivable, account_payable = statement_obj.get_default_pay_receiv_accounts(
85- cr, uid, context)
86 try:
87 # Record every line in the bank statement
88 statement_store = []
89 for line in result_row_list:
90 parser_vals = parser.get_st_line_vals(line)
91 values = self.prepare_statement_lines_vals(
92- cr, uid, parser_vals, account_payable, account_receivable, statement_id,
93+ cr, uid, parser_vals, statement_id,
94 context)
95 statement_store.append(values)
96 # Hack to bypass ORM poor perfomance. Sob...
97@@ -232,11 +225,3 @@
98 raise osv.except_osv(_("Statement import error"),
99 _("The statement cannot be created: %s") % st)
100 return statement_id
101-
102-
103-class AccountBankStatementLine(Model):
104- _inherit = "account.bank.statement.line"
105-
106- _columns = {
107- 'account_id': fields.many2one('account.account', 'Account'),
108- }

Subscribers

People subscribed via source and target branches