banking-addons-team team mailing list archive
-
banking-addons-team team
-
Mailing list archive
-
Message #01286
lp:~acsone-openerp/banking-addons/bank-statement-reconcile-70-import-statement-hook into lp:banking-addons/bank-statement-reconcile-7.0
Laurent Mignon (Acsone) has proposed merging lp:~acsone-openerp/banking-addons/bank-statement-reconcile-70-import-statement-hook into lp:banking-addons/bank-statement-reconcile-7.0.
Requested reviews:
Banking Addons Core Editors (banking-addons-team)
For more details, see:
https://code.launchpad.net/~acsone-openerp/banking-addons/bank-statement-reconcile-70-import-statement-hook/+merge/201732
Hi,
In some cases, the imported file may contains information about the account.bank.statement.
The proposal add a new method 'get_st_vals' on the 'BankStatementImportParser' that can be used to provide statement info from the parsed file and a new method 'prepare_statement_vals' on 'AccountStatementProfil' that fills the statement values with the profile_id and the result to the call to the new method on the parser.
--
https://code.launchpad.net/~acsone-openerp/banking-addons/bank-statement-reconcile-70-import-statement-hook/+merge/201732
Your team Banking Addons Core Editors is requested to review the proposed merge of lp:~acsone-openerp/banking-addons/bank-statement-reconcile-70-import-statement-hook into lp:banking-addons/bank-statement-reconcile-7.0.
=== modified file 'account_statement_base_completion/statement.py'
--- account_statement_base_completion/statement.py 2013-10-16 08:58:12 +0000
+++ account_statement_base_completion/statement.py 2014-01-15 09:09:31 +0000
@@ -182,7 +182,7 @@
inv = self._find_invoice(cr, uid, line, inv_type, context=context)
if inv:
# FIXME use only commercial_partner_id of invoice in 7.1
- # this is for backward compatibility in 7.0 before
+ # this is for backward compatibility in 7.0 before
# the refactoring of res.partner
if hasattr(inv, 'commercial_partner_id'):
partner_id = inv.commercial_partner_id.id
@@ -459,7 +459,7 @@
"""
statement_line_obj = self.pool['account.bank.statement.line']
model_cols = statement_line_obj._columns
- sparse_fields = dict([(k , col) for k, col in model_cols.iteritems() if isinstance(col, fields.sparse) and col._type == 'char'])
+ sparse_fields = dict([(k, col) for k, col in model_cols.iteritems() if isinstance(col, fields.sparse) and col._type == 'char'])
values = []
for statement in statement_store:
to_json_k = set()
@@ -470,10 +470,9 @@
serialized = st_copy.setdefault(col.serialization_field, {})
serialized[k] = st_copy[k]
for k in to_json_k:
- st_copy[k] = simplejson.dumps(st_copy[k])
+ st_copy[k] = simplejson.dumps(st_copy[k])
values.append(st_copy)
return values
-
def _insert_lines(self, cr, uid, statement_store, context=None):
""" Do raw insert into database because ORM is awfully slow
@@ -497,7 +496,7 @@
when cheking security.
TODO / WARM: sparse fields are skipped by the method. IOW, if your
completion rule update an sparse field, the updated value will never
- be stored in the database. It would be safer to call the update method
+ be stored in the database. It would be safer to call the update method
from the ORM for records updating this kind of fields.
"""
cols = self._get_available_columns([vals])
=== modified file 'account_statement_base_import/parser/parser.py'
--- account_statement_base_import/parser/parser.py 2013-05-03 19:57:26 +0000
+++ account_statement_base_import/parser/parser.py 2014-01-15 09:09:31 +0000
@@ -110,6 +110,14 @@
"""
return NotImplementedError
+ def get_st_vals(self):
+ """
+ This method return a dict of vals that ca be passed to
+ create method of statement.
+ :return: dict of vals that represent additional infos for the statement
+ """
+ return {}
+
def get_st_line_vals(self, line, *args, **kwargs):
"""
Implement a method in your parser that must return a dict of vals that can be
=== modified file 'account_statement_base_import/statement.py'
--- account_statement_base_import/statement.py 2013-09-12 09:05:01 +0000
+++ account_statement_base_import/statement.py 2014-01-15 09:09:31 +0000
@@ -90,7 +90,7 @@
statement_id, context):
"""
Hook to build the values of a line from the parser returned values. At
- least it fullfill the statement_id and account_id. Overide it to add your
+ least it fullfill the statement_id and account_id. Override it to add your
own completion if needed.
:param dict of vals from parser for account.bank.statement.line (called by
@@ -126,6 +126,15 @@
values['type'] = 'general'
return values
+ def prepare_statement_vals(self, cr, uid, profile_id, result_row_list, parser, context):
+ """
+ Hook to build the values of the statement from the parser and
+ the profile.
+ """
+ vals = {'profile_id': profile_id}
+ vals.update(parser.get_st_vals())
+ return vals
+
def statement_import(self, cr, uid, ids, profile_id, file_stream, ftype="csv", context=None):
"""
Create a bank statement with the given profile and parser. It will fullfill the bank statement
@@ -159,9 +168,11 @@
_("Column %s you try to import is not "
"present in the bank statement line!") % col)
+ statement_vals = self.prepare_statement_vals(cr, uid, prof.id, result_row_list, parser, context)
statement_id = statement_obj.create(cr, uid,
- {'profile_id': prof.id},
+ statement_vals,
context=context)
+
if prof.receivable_account_id:
account_receivable = account_payable = prof.receivable_account_id.id
else:
Follow ups