mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-19 11:52:18 -06:00
[IMP] document_page_access_group: Users compatibility
TT48786
This commit is contained in:
committed by
Bhavesh Heliconia
parent
a6e2e785f8
commit
f57f6b6fe2
@@ -1,10 +1,19 @@
|
||||
# Copyright 2022 Manuel Regidor <manuel.regidor@sygel.es>
|
||||
# Copyright 2024 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class DocumentPage(models.Model):
|
||||
_inherit = "document.page"
|
||||
|
||||
groups_id = fields.Many2many(comodel_name="res.groups", string="Groups")
|
||||
user_ids = fields.Many2many(comodel_name="res.users", string="Users")
|
||||
|
||||
@api.constrains("groups_id", "user_ids")
|
||||
def check_document_page_groups_users(self):
|
||||
for _item in self.filtered(lambda x: x.groups_id and x.user_ids):
|
||||
raise UserError(_("You cannot set groups and users at the same time."))
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user