Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4 Відповіді
7460 Переглядів

I have a button in (stock_picking form) that I want to hide from a certain user (I know the DB user_id but I realize that would be ugly). I tried with the invisible attribute but I dont have the user_id in the form. 


Do you have a recommended way of achieving this? Perhaps adding this user to a usergroup with a specific name, and then filtering out this group somehow in the view. 

Аватар
Відмінити
Найкраща відповідь

Hi Edi,

You can do it using fields_view_get method.

Please check this link / answer. There is a similar question..

Аватар
Відмінити

or security groups, right?

Найкраща відповідь

Dear Adi

Try this


    @api.model
    def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
        res=super(PickingClass, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
        if view_type != 'search' and not(self.env.user.has_group('YourModule.YourGroup')):
                root = etree.fromstring(res['arch'])
                root.set('create', 'false')
                res['arch'] = etree.tostring(root)
        return res


I hope I helped You...

Аватар
Відмінити
Найкраща відповідь

Hello, 

you can achieve this either by fields_view_get or using the security rights.

for the security group, make one security group and assign that group on the button. then whom you assign that group, only that user can see the button.

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
5
лип. 18
6246
2
бер. 25
5770
5
серп. 24
46641
2
квіт. 24
2551
3
черв. 23
5781