From 87466ae9788df502bc21eb6a7c05c7f9289f9055 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Tue, 23 Jun 2015 16:37:06 +0200 Subject: [PATCH 1/3] [FIX] account_bank_statement_import: Handle correctly the selection of the journal --- .../account_bank_statement_import.py | 10 +++------- .../account_bank_statement_import_qif.py | 15 --------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/account_bank_statement_import/account_bank_statement_import.py b/account_bank_statement_import/account_bank_statement_import.py index c37460f..9678a2b 100644 --- a/account_bank_statement_import/account_bank_statement_import.py +++ b/account_bank_statement_import/account_bank_statement_import.py @@ -170,11 +170,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 +187,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 +195,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 diff --git a/account_bank_statement_import_qif/account_bank_statement_import_qif.py b/account_bank_statement_import_qif/account_bank_statement_import_qif.py index 2683e77..0b9061e 100644 --- a/account_bank_statement_import_qif/account_bank_statement_import_qif.py +++ b/account_bank_statement_import_qif/account_bank_statement_import_qif.py @@ -15,21 +15,6 @@ class AccountBankStatementImport(models.TransientModel): def _get_hide_journal_field(self): return self.env.context.get('journal_id') and True - @api.model - def _get_journal(self, currency_id, bank_account_id, account_number): - """ As .QIF format does not allow us to detect the journal, we need to - let the user choose it. - We set it in context before to call super so it's the same as - calling the widget from a journal """ - record = self - active_id = self.env.context.get('active_id') - if active_id: - record = self.browse(active_id) - if record.journal_id: - record = record.with_context(journal_id=record.journal_id.id) - return super(AccountBankStatementImport, record)._get_journal( - currency_id, bank_account_id, account_number) - @api.model def _check_qif(self, data_file): return data_file.strip().startswith('!Type:') From f028947355e8b7024b29732d99ad136e185d8460 Mon Sep 17 00:00:00 2001 From: Antonio Espinosa Date: Wed, 24 Jun 2015 11:30:21 +0200 Subject: [PATCH 2/3] [FIX] Change default by compute and between quotes in order to allow inheritance --- account_bank_statement_import/account_bank_statement_import.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_bank_statement_import/account_bank_statement_import.py b/account_bank_statement_import/account_bank_statement_import.py index 9678a2b..3b1c79e 100644 --- a/account_bank_statement_import/account_bank_statement_import.py +++ b/account_bank_statement_import/account_bank_statement_import.py @@ -40,7 +40,7 @@ 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) + '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 ' From c8f95fbaefaa42f01f1d7a3133751f0c0c8218f9 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 25 Jun 2015 11:46:37 +0200 Subject: [PATCH 3/3] [FIX] account_bank_statement_import: PEP8 --- account_bank_statement_import/account_bank_statement_import.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/account_bank_statement_import/account_bank_statement_import.py b/account_bank_statement_import/account_bank_statement_import.py index 3b1c79e..6ed3b32 100644 --- a/account_bank_statement_import/account_bank_statement_import.py +++ b/account_bank_statement_import/account_bank_statement_import.py @@ -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', compute='_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 '