mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[ADD] account_account_constraint_code
This commit is contained in:
22
account_account_constraint_code/models/account_account.py
Normal file
22
account_account_constraint_code/models/account_account.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Copyright 2022 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import _, api, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class AccountAccount(models.Model):
|
||||
|
||||
_inherit = "account.account"
|
||||
|
||||
@api.constrains("code")
|
||||
def _disable_code_modification(self):
|
||||
line = (
|
||||
self.env["account.move.line"]
|
||||
.sudo()
|
||||
.search([("account_id", "in", self.ids)], limit=1)
|
||||
)
|
||||
if line:
|
||||
raise ValidationError(
|
||||
_("You cannot change the code of account which contains journal items.")
|
||||
)
|
||||
Reference in New Issue
Block a user