From 7aa8ac004a790ee092e2208d674e8f8e8a134bcd Mon Sep 17 00:00:00 2001 From: "Paolo (pgi)" Date: Fri, 30 Sep 2022 16:12:08 +0000 Subject: [PATCH] [FIX] account: When filling gaps, create button has bad default journal When using the "Holes in sequence" shortcut on a journal in the Dashboard, the "Create" form shows the Miscellanous Entries journal as a default instead of the same Journal that the user trying to fix. https://watch.screencastify.com/v/kUorLSIHwoy97UKuDJBC closes odoo/odoo#101926 X-original-commit: a8f9950d6d55137f9c9de15042f6cb717e4a7140 Signed-off-by: Cedric Snauwaert Signed-off-by: Paolo Gatti (pgi) --- addons/account/models/account_journal_dashboard.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py index 8db08f9ff60..fd6829ec88f 100644 --- a/addons/account/models/account_journal_dashboard.py +++ b/addons/account/models/account_journal_dashboard.py @@ -430,7 +430,7 @@ class account_journal(models.Model): rslt_sum += target_currency.round(amount) return (rslt_count, rslt_sum) - def action_create_new(self): + def _get_move_action_context(self): ctx = self._context.copy() ctx['default_journal_id'] = self.id if self.type == 'sale': @@ -440,13 +440,16 @@ class account_journal(models.Model): else: ctx['default_move_type'] = 'entry' ctx['view_no_maturity'] = True + return ctx + + def action_create_new(self): return { 'name': _('Create invoice/bill'), 'type': 'ir.actions.act_window', 'view_mode': 'form', 'res_model': 'account.move', 'view_id': self.env.ref('account.view_move_form').id, - 'context': ctx, + 'context': self._get_move_action_context(), } def create_cash_statement(self): @@ -587,6 +590,7 @@ class account_journal(models.Model): for journal_id, prefix in has_sequence_holes ), 'context': { + **self._get_move_action_context(), 'search_default_group_by_sequence_prefix': 1, 'expand': 1, }