|
@ -133,6 +133,8 @@ class account_bank_statement_import(osv.TransientModel): |
|
|
|
|
|
|
|
|
def _get_journal(self, cr, uid, currency_id, bank_account_id, account_number, context=None): |
|
|
def _get_journal(self, cr, uid, currency_id, bank_account_id, account_number, context=None): |
|
|
""" Find or create the journal """ |
|
|
""" Find or create the journal """ |
|
|
|
|
|
if context is None: |
|
|
|
|
|
context = {} |
|
|
bank_pool = self.pool.get('res.partner.bank') |
|
|
bank_pool = self.pool.get('res.partner.bank') |
|
|
|
|
|
|
|
|
# Find the journal from context or bank account |
|
|
# Find the journal from context or bank account |
|
@ -155,11 +157,11 @@ class account_bank_statement_import(osv.TransientModel): |
|
|
raise Warning(_('The currency of the bank statement is not the same as the currency of the journal !')) |
|
|
raise Warning(_('The currency of the bank statement is not the same as the currency of the journal !')) |
|
|
|
|
|
|
|
|
# If there is no journal, create one (and its account) |
|
|
# If there is no journal, create one (and its account) |
|
|
# I think it's too dangerous, so I disable that code -- Alexis de Lattre |
|
|
|
|
|
#if not journal_id and account_number: |
|
|
|
|
|
# journal_id = self._create_journal(cr, uid, currency_id, account_number, context=context) |
|
|
|
|
|
# if bank_account_id: |
|
|
|
|
|
# bank_pool.write(cr, uid, [bank_account_id], {'journal_id': journal_id}, context=context) |
|
|
|
|
|
|
|
|
# I think it's too dangerous, so I disable that code by default -- Alexis de Lattre |
|
|
|
|
|
if context.get('allow_auto_create_journal') and not journal_id and account_number: |
|
|
|
|
|
journal_id = self._create_journal(cr, uid, currency_id, account_number, context=context) |
|
|
|
|
|
if bank_account_id: |
|
|
|
|
|
bank_pool.write(cr, uid, [bank_account_id], {'journal_id': journal_id}, context=context) |
|
|
|
|
|
|
|
|
# If we couldn't find/create a journal, everything is lost |
|
|
# If we couldn't find/create a journal, everything is lost |
|
|
if not journal_id: |
|
|
if not journal_id: |
|
|