|
|
@ -40,7 +40,8 @@ class AccountBankStatementImport(models.TransientModel): |
|
|
|
'importing. It has be be manually chosen for statement formats which ' |
|
|
|
'doesn\'t allow automatic journal detection (QIF for example).') |
|
|
|
hide_journal_field = fields.Boolean( |
|
|
|
'Hide the journal field in the view', default=_get_hide_journal_field) |
|
|
|
string='Hide the journal field in the view', |
|
|
|
compute='_get_hide_journal_field') |
|
|
|
data_file = fields.Binary( |
|
|
|
'Bank Statement File', required=True, |
|
|
|
help='Get you bank statements in electronic format from your bank ' |
|
|
@ -170,11 +171,10 @@ class AccountBankStatementImport(models.TransientModel): |
|
|
|
|
|
|
|
@api.model |
|
|
|
def _get_journal(self, currency_id, bank_account_id, account_number): |
|
|
|
""" Find or create the journal """ |
|
|
|
""" Find the journal """ |
|
|
|
bank_model = self.env['res.partner.bank'] |
|
|
|
|
|
|
|
# Find the journal from context or bank account |
|
|
|
journal_id = self.env.context.get('journal_id') |
|
|
|
# Find the journal from context, wizard or bank account |
|
|
|
journal_id = self.env.context.get('journal_id') or self.journal_id.id |
|
|
|
if bank_account_id: |
|
|
|
bank_account = bank_model.browse(bank_account_id) |
|
|
|
if journal_id: |
|
|
@ -188,7 +188,6 @@ class AccountBankStatementImport(models.TransientModel): |
|
|
|
else: |
|
|
|
if bank_account.journal_id.id: |
|
|
|
journal_id = bank_account.journal_id.id |
|
|
|
|
|
|
|
# If importing into an existing journal, its currency must be the same |
|
|
|
# as the bank statement |
|
|
|
if journal_id: |
|
|
@ -197,12 +196,10 @@ class AccountBankStatementImport(models.TransientModel): |
|
|
|
if currency_id and currency_id != journal_currency_id: |
|
|
|
raise Warning(_('The currency of the bank statement is not ' |
|
|
|
'the same as the currency of the journal !')) |
|
|
|
|
|
|
|
# If we couldn't find/create a journal, everything is lost |
|
|
|
if not journal_id: |
|
|
|
raise Warning(_('Cannot find in which journal import this ' |
|
|
|
'statement. Please manually select a journal.')) |
|
|
|
|
|
|
|
return journal_id |
|
|
|
|
|
|
|
@api.model |
|
|
|