From b31f7786f455574a0644294a91b652986abf6ee4 Mon Sep 17 00:00:00 2001 From: Chirag Vaghela Date: Fri, 18 Aug 2017 15:59:55 +0200 Subject: [PATCH] [IMP] account: dynamically display invoice filters depending on the context: When displaying only invoices, a "Credit notes" filter is useless (and vice-versa). Filters will be called "Not draft" When displaying both, keep filters for Invoices and Credit Notes. --- .../models/account_journal_dashboard.py | 3 ++ addons/account/views/account_invoice_view.xml | 42 ++++++++++++++++--- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py index 361962fa29f..663d7922236 100644 --- a/addons/account/models/account_journal_dashboard.py +++ b/addons/account/models/account_journal_dashboard.py @@ -351,6 +351,9 @@ class account_journal(models.Model): [action] = self.env.ref('account.%s' % action_name).read() action['context'] = ctx action['domain'] = self._context.get('use_domain', []) + account_invoice_filter = self.env.ref('account.view_account_invoice_filter', False) + if action_name in ['action_invoice_tree1', 'action_invoice_tree2']: + action['search_view_id'] = account_invoice_filter and account_invoice_filter.id or False if action_name in ['action_bank_statement_tree', 'action_view_bank_statement_tree']: action['views'] = False action['view_id'] = False diff --git a/addons/account/views/account_invoice_view.xml b/addons/account/views/account_invoice_view.xml index 71cd0f878f0..e1a0c6a3334 100644 --- a/addons/account/views/account_invoice_view.xml +++ b/addons/account/views/account_invoice_view.xml @@ -522,8 +522,8 @@ - - + + @@ -557,6 +557,36 @@ + + account.invoice.select.invoices + account.invoice + primary + + + + + Not Draft + + + + + + + + account.invoice.select.credit.notes + account.invoice + primary + + + + + Not Draft + + + + + + Invoices account.invoice @@ -624,7 +654,7 @@ [('type','=','out_invoice')] {'type':'out_invoice', 'journal_type': 'sale'} - +

Click to create a customer invoice. @@ -665,7 +695,7 @@ [('type','=','out_refund')] {'default_type': 'out_refund', 'journal_type': 'sale'} - +

Click to create a credit note. @@ -703,7 +733,7 @@ [('type','=','in_invoice')] {'default_type': 'in_invoice', 'type': 'in_invoice', 'journal_type': 'purchase'} - +

Click to record a new vendor bill. @@ -739,7 +769,7 @@ [('type','=','in_refund')] {'default_type': 'in_refund', 'journal_type': 'purchase'} - +

Click to record a new vendor credit note.