[FIX] account: set a journal bank_statements_source after it succeeds

When a bank statement acquisition method (file import, plaid, manual encoding)
is used on a journal, it should only be set as the journal's
bank_statements_source after successful completion.
This commit is contained in:
Arthur Maniet
2015-08-21 16:43:25 +02:00
parent 3a4848e3a9
commit 857156e33e
2 changed files with 2 additions and 2 deletions
@@ -46,6 +46,8 @@ class AccountBankStatementImport(models.TransientModel):
stmts_vals = self._complete_stmts_vals(stmts_vals, journal, account_number)
# Create the bank statements
statement_ids, notifications = self._create_bank_statements(stmts_vals)
# Now that the import worked out, set it as the bank_statements_source of the journal
journal.bank_statements_source = 'file_import'
# Finally dispatch to reconciliation interface
action = self.env.ref('account.action_bank_reconcile_bank_statements')
return {
@@ -73,7 +75,6 @@ class AccountBankStatementImport(models.TransientModel):
'default_name': _('Bank') + ' ' + account_number,
'default_currency_id': currency and currency.id or False,
'default_type': 'bank',
'default_bank_statements_source': 'file_import',
}
}
@@ -10,7 +10,6 @@ class AccountJournal(models.Model):
@api.multi
def import_statement(self):
"""return action to import bank/cash statements. This button should be called only on journals with type =='bank'"""
self.bank_statements_source = 'file_import'
model = 'account.bank.statement'
action_name = 'action_account_bank_statement_import'
ir_model_obj = self.pool['ir.model.data']