From 70226284b33032855c614870bbd58a4ed4d9a33b Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 4 Aug 2014 13:14:33 +0200 Subject: [PATCH 1/2] [IMP] account_statement_base_import: Fill balance start when parser doesn't filled it --- account_statement_base_import/statement.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/account_statement_base_import/statement.py b/account_statement_base_import/statement.py index b1497f48..6e0c67f1 100644 --- a/account_statement_base_import/statement.py +++ b/account_statement_base_import/statement.py @@ -127,12 +127,21 @@ class AccountStatementProfil(Model): values = statement_line_obj._add_missing_default_values(cr, uid, values, context) return values - def prepare_statement_vals(self, cr, uid, profile_id, result_row_list, parser, context): + def prepare_statement_vals(self, cr, uid, profile_id, result_row_list, + parser, context=None): """ Hook to build the values of the statement from the parser and the profile. """ vals = {'profile_id': profile_id} + if not vals.get('balance_start'): + # Get starting balance from journal balance if parser doesn't + # fill this data, simulating the manual flow + statement_obj = self.pool['account.bank.statement'] + profile = self.browse(cr, uid, profile_id, context=context) + temp = statement_obj.onchange_journal_id( + cr, uid, None, profile.journal_id.id, context=context) + vals['balance_start'] = temp['value'].get('balance_start', False) vals.update(parser.get_st_vals()) return vals From 69c0e16a5b9d7a46412f3003201075f099cd742b Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 4 Aug 2014 13:48:51 +0200 Subject: [PATCH 2/2] [FIX] Correct call order --- account_statement_base_import/statement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_statement_base_import/statement.py b/account_statement_base_import/statement.py index 6e0c67f1..67879665 100644 --- a/account_statement_base_import/statement.py +++ b/account_statement_base_import/statement.py @@ -134,6 +134,7 @@ class AccountStatementProfil(Model): the profile. """ vals = {'profile_id': profile_id} + vals.update(parser.get_st_vals()) if not vals.get('balance_start'): # Get starting balance from journal balance if parser doesn't # fill this data, simulating the manual flow @@ -142,7 +143,6 @@ class AccountStatementProfil(Model): temp = statement_obj.onchange_journal_id( cr, uid, None, profile.journal_id.id, context=context) vals['balance_start'] = temp['value'].get('balance_start', False) - vals.update(parser.get_st_vals()) return vals def multi_statement_import(self, cr, uid, ids, profile_id, file_stream,