-
-
Notifications
You must be signed in to change notification settings - Fork 965
Expand file tree
/
Copy pathres_partner.py
More file actions
35 lines (30 loc) · 1.14 KB
/
res_partner.py
File metadata and controls
35 lines (30 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import api, models
from odoo.exceptions import AccessError
from odoo.tools import config
class ResPartner(models.Model):
_inherit = "res.partner"
@api.model
def check_access(self, operation):
"""Simulate that you do not have ACLs so that the create, edit and delete
buttons are not displayed."""
user = self.env.user
group = "partner_readonly_security.group_partner_edition"
test_condition = not config["test_enable"] or (
config["test_enable"]
and self.env.context.get("test_partner_readonly_security")
)
if (
test_condition
and operation != "read"
and not self.env.su
and not user.has_group(group)
):
raise AccessError(
self.env._(
"Sorry, you are not allowed to create/edit partners. Please "
"contact your administrator for further information."
)
)
return super().check_access(operation)