[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 <las@odoo.com>
This commit is contained in:
Nicolas (vin)
2022-04-01 17:56:38 +02:00
parent f0e1e60528
commit e2b3ec6d5c
2 changed files with 10 additions and 1 deletions
+10
View File
@@ -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 {
@@ -273,7 +273,6 @@
<field name="arch" type="xml">
<field name="account_id" position="attributes">
<attribute name="optional">hide</attribute>
<attribute name="readonly">1</attribute>
</field>
<field name="balance" position="attributes"><attribute name="optional">show</attribute></field>
<field name="balance" position="after">