2019-08-26 21:28:27 +02:00
|
|
|
# Copyright 2009-2018 Noviat
|
2019-08-31 12:14:51 +02:00
|
|
|
# Copyright 2019 Tecnativa - Pedro M. Baeza
|
2019-08-26 21:28:27 +02:00
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
|
|
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
|
|
|
|
|
|
class AccountAssetGroup(models.Model):
|
2020-01-29 18:34:31 +01:00
|
|
|
_name = "account.asset.group"
|
|
|
|
_description = "Asset Group"
|
|
|
|
_order = "name"
|
2019-08-31 12:14:51 +02:00
|
|
|
_parent_store = True
|
2019-08-26 21:28:27 +02:00
|
|
|
|
2020-01-29 18:34:31 +01:00
|
|
|
name = fields.Char(string="Name", size=64, required=True, index=True)
|
2019-08-31 12:14:51 +02:00
|
|
|
code = fields.Char(index=True)
|
|
|
|
parent_path = fields.Char(index=True)
|
2019-08-26 21:28:27 +02:00
|
|
|
company_id = fields.Many2one(
|
2020-01-29 18:34:31 +01:00
|
|
|
comodel_name="res.company",
|
|
|
|
string="Company",
|
2019-08-31 12:14:51 +02:00
|
|
|
required=True,
|
2020-01-29 18:34:31 +01:00
|
|
|
default=lambda self: self._default_company_id(),
|
|
|
|
)
|
2019-08-26 21:28:27 +02:00
|
|
|
parent_id = fields.Many2one(
|
2020-01-29 18:34:31 +01:00
|
|
|
comodel_name="account.asset.group",
|
|
|
|
string="Parent Asset Group",
|
|
|
|
ondelete="restrict",
|
|
|
|
)
|
2019-08-26 21:28:27 +02:00
|
|
|
|
|
|
|
@api.model
|
|
|
|
def _default_company_id(self):
|
2020-01-29 18:37:08 +01:00
|
|
|
return self.env.company
|