Browse Source

Re-activate the code to auto-create journal, but needs a special key in context

pull/6/head
Alexis de Lattre 10 years ago
parent
commit
6da8103d22
  1. 12
      account_bank_statement_import/account_bank_statement_import.py

12
account_bank_statement_import/account_bank_statement_import.py

@ -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):
""" Find or create the journal """
if context is None:
context = {}
bank_pool = self.pool.get('res.partner.bank')
# 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 !'))
# 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 not journal_id:

Loading…
Cancel
Save