You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.5 KiB
83 lines
2.5 KiB
# Copyright 2019 Myceliandre - Nicolas JEUDY
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class PersonalDataCategory(models.Model):
|
|
_name = "privacy.personal.category"
|
|
_description = "Personal Data category"
|
|
_parent_name = "parent_id"
|
|
_parent_store = True
|
|
_rec_name = "complete_name"
|
|
_order = "complete_name"
|
|
|
|
name = fields.Char("Name", index=True, required=True, translate=True)
|
|
description = fields.Html(
|
|
translate=True, help="Give more example, explanation of personal data"
|
|
)
|
|
complete_name = fields.Char(
|
|
"Complete Name", compute="_compute_complete_name", store=True
|
|
)
|
|
parent_id = fields.Many2one(
|
|
"privacy.personal.category", "Parent Category", index=True, ondelete="cascade"
|
|
)
|
|
parent_path = fields.Char(index=True)
|
|
type = fields.Selection(
|
|
[("common", "Common"), ("risk", "High Risk"), ("sensitive", "Sensitive")],
|
|
string="Type",
|
|
default="common",
|
|
required=True,
|
|
)
|
|
child_id = fields.One2many(
|
|
"privacy.personal.category", "parent_id", "Child Categories"
|
|
)
|
|
|
|
@api.depends("name", "parent_id.complete_name")
|
|
def _compute_complete_name(self):
|
|
for category in self:
|
|
if category.parent_id:
|
|
category.complete_name = "%s / %s" % (
|
|
category.parent_id.complete_name,
|
|
category.name,
|
|
)
|
|
else:
|
|
category.complete_name = category.name
|
|
|
|
@api.constrains("parent_id")
|
|
def _check_category_recursion(self):
|
|
if not self._check_recursion():
|
|
raise ValidationError(_("You cannot create recursive categories."))
|
|
return True
|
|
|
|
@api.model
|
|
def name_create(self, name):
|
|
return self.create({"name": name}).name_get()[0]
|
|
|
|
|
|
class PersonalData(models.Model):
|
|
_name = "privacy.personal.data"
|
|
_description = "Personal Data"
|
|
|
|
active = fields.Boolean(
|
|
default=True,
|
|
index=True,
|
|
)
|
|
name = fields.Char(
|
|
index=True,
|
|
required=True,
|
|
translate=True,
|
|
)
|
|
description = fields.Html(translate=True, help="Data list used in activity")
|
|
|
|
categ_id = fields.Many2one(
|
|
"privacy.personal.category",
|
|
string="Category",
|
|
domain=[("child_id", "=", False)],
|
|
)
|
|
type = fields.Selection(
|
|
related="categ_id.type",
|
|
)
|
|
|
|
data_month_before_erasing = fields.Integer("Erasing delay (month)")
|
|
legal_erasing = fields.Integer("Legal Erasing (month)")
|