From e2b3ec6d5c8a2f28b972a5aecebfcf68b7913172 Mon Sep 17 00:00:00 2001 From: "Nicolas (vin)" Date: Thu, 31 Mar 2022 10:34:23 +0000 Subject: [PATCH] [IMP] account_*: some Back2Basics improvements Improve a few things in accounts modules: - Users wants to be able to change the account in the general ledger list view - Do not group by date by default when auditing a tax line. - Make the currency fields only show in debug mode for accounts and assets - Disallow to delete taxes linked to a tax repartition line, and clarify the error message when trying to delete one linked to a fiscal position's account mapping Task id # 2810379 [IMP] account_*: some Back2Basics improvements Improve a few things in accounts modules: - Users wants to be able to change the account in the general ledger list view - Do not group by date by default when auditing a tax line. - Disallow to delete taxes linked to a tax repartition line, and clarify the error message when trying to delete one linked to a fiscal position's account mapping Task id # 2810379 closes odoo/odoo#87659 Related: odoo/enterprise#25770 Signed-off-by: Laurent Smet --- addons/account/models/account_account.py | 10 ++++++++++ addons/account/views/account_move_views.xml | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_account.py b/addons/account/models/account_account.py index 01dac4ee6a7..a967fc334df 100644 --- a/addons/account/models/account_account.py +++ b/addons/account/models/account_account.py @@ -575,6 +575,16 @@ class AccountAccount(models.Model): _('You cannot remove/deactivate the account %s which is set on a customer or vendor.', account_name) ) + @api.ondelete(at_uninstall=False) + def _unlink_except_linked_to_fiscal_position(self): + if self.env['account.fiscal.position.account'].search(['|', ('account_src_id', 'in', self.ids), ('account_dest_id', 'in', self.ids)], limit=1): + raise UserError(_('You cannot remove/deactivate the accounts "%s" which are set on the account mapping of a fiscal position.', ', '.join(f"{a.code} - {a.name}" for a in self))) + + @api.ondelete(at_uninstall=False) + def _unlink_except_linked_to_tax_repartition_line(self): + if self.env['account.tax.repartition.line'].search([('account_id', 'in', self.ids)], limit=1): + raise UserError(_('You cannot remove/deactivate the accounts "%s" which are set on a tax repartition line.', ', '.join(f"{a.code} - {a.name}" for a in self))) + def action_read_account(self): self.ensure_one() return { diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index 401e519d65b..bc68df556e1 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -273,7 +273,6 @@ hide - 1 show