From 04ed2dec6ffbaad9568b187d6d8b81722a508a06 Mon Sep 17 00:00:00 2001 From: Adrien Dieudonne Date: Tue, 29 Dec 2020 13:16:31 +0000 Subject: [PATCH] [FIX] account: open form view when single invoice generated Before this commit, there was no difference whether multiple invoices were uploaded or not. The list view was always opened. Now, the form view is automatically opened when a single bill is uploaded. Task-ID: 2152183 --- addons/account/models/account_journal.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account_journal.py b/addons/account/models/account_journal.py index dd1c011cee3..295c63d2b5f 100644 --- a/addons/account/models/account_journal.py +++ b/addons/account/models/account_journal.py @@ -659,14 +659,20 @@ class AccountJournal(models.Model): 'name': _('Generated Documents'), 'domain': [('id', 'in', invoices.ids)], 'res_model': 'account.move', - 'views': [[False, "tree"], [False, "form"]], 'type': 'ir.actions.act_window', 'context': self._context } if len(invoices) == 1: - action_vals.update({'res_id': invoices[0].id, 'view_mode': 'form'}) + action_vals.update({ + 'views': [[False, "form"]], + 'view_mode': 'form', + 'res_id': invoices[0].id, + }) else: - action_vals['view_mode'] = 'tree,form' + action_vals.update({ + 'views': [[False, "tree"], [False, "form"]], + 'view_mode': 'tree,form', + }) return action_vals def _create_invoice_from_single_attachment(self, attachment):