mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
Re-activate the code to auto-create journal, but needs a special key in context
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user