2
0
account-financial-tools/account_asset_management/models/account_account.py
2022-12-24 00:42:21 +01:00

30 lines
946 B
Python

# Copyright 2009-2017 Noviat
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class AccountAccount(models.Model):
_inherit = "account.account"
asset_profile_id = fields.Many2one(
comodel_name="account.asset.profile",
string="Asset Profile",
help="Default Asset Profile when creating invoice lines " "with this account.",
)
@api.constrains("asset_profile_id")
def _check_asset_profile(self):
for account in self:
if (
account.asset_profile_id
and account.asset_profile_id.account_asset_id != account
):
raise ValidationError(
_(
"The Asset Account defined in the Asset Profile "
"must be equal to the account."
)
)