Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
5 Ответы
6229 Представления

I know that it is possible to restrict access to form elements using the groups attribute. However, I am wondering if it is possible to restrict access to a form element based off of the current values of the current user's permissions.

For example, let's say I have a group named "group_a", and let's say I have a record called "my_record". Let's also say that "group_a" has read and create permissions for "my_record", but "group_a" can only write and delete the instances of "my_record" that they create. This rule is easily established using a record rule.

As you can see, "group_a" has conditional write and delete permissions over "my_record". I would like to hide the "Edit" and "Delete" buttons when the current user does not have write and delete permissions for the current record. How can I do this?

Аватар
Отменить

Record rule will do it right, you itself has mentioned that in the question, then what is the issue

Автор

@Niyas I know of now way to hide a form element using record rules. I would like the actual "Edit" and "Delete" buttons in the view to disappear when the current user does not have write or delete permissions.

Hiding of the create edit delete button also can be done using the record rules and access control list

Лучший ответ

Hi,

Better you can use Access control for this, create a CSV file inside your module and add like this,

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_my_record,access.my.record,module_name.my_record,module_name.group_a,1,0,0,0


You can assign read, write, create and delete permission like this if you set create 0, then user cant see create button for this model and for this group of users.


Thanks

Аватар
Отменить
Лучший ответ

You can use:

python:

user = self.env['res.users'].browse(self.env.uid)

isgroup = user.has_group('your_group')

and you override write, create method


Аватар
Отменить
Related Posts Ответы Просмотры Активность
4
дек. 22
7450
2
мар. 25
5763
5
авг. 24
46619
2
апр. 24
2546
3
июн. 23
5770