Skip to Content
Menu
This question has been flagged
1 Reply
6672 Views

Hi 

I want to hide kanban view's progress bar for some user. how to do this please if know the solution please let me know.

see my code

.py file 

class CRMLead(models.Model):
    _inherit = 'crm.lead'

    is_admin = fields.Boolean(compute="check_user_group")
    def check_user_group(self):
        self.is_admin = self.env['res.users'].has_group('base.user_admin')

.xml file

<xpath expr="//progressbar[@field='activity_state']" position="attributes">

<attribute name="attrs">{'invisible':[('is_admin','!=',True)]}</attribute>

</xpath>

This above code does not work for me

Avatar
Discard
Best Answer

Hi,

Your code will hide for all users except admins but you need to add is_admin field to kanban view to be able to use it in domains.

<xpath expr="//field[@name='activity_state']" position="after">
<field name='is_admin' invisible="1"/>
</xpath>

If it's not work try the below please try the below: 

You can create a security group and it will be disabled for all users except root and admins and you can give access to users individually.  

<record id="view_progress_bar" model="res.groups">
<field name="name">View Progress bar</field>
<!-- Add super user and admin to group, you can delete the below line to hide for them as well --> 
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>

</record>


Then inherit view and add the below:

<xpath expr="//progressbar[@field='activity_state']" position="attributes">
<attribute name="groups">[YOUR_Module_Name].view_progress_bar</attribute>
</xpath>

Then and for each user you want to view the progress bar, you will enable developer mode then go Settings -> users -> open required user

Edit the user record and you will see at the bottom your create group with Checkbox named "View Progress bar" and you will check it to allow user to view progress bar.

Please up vote if this help.

Avatar
Discard
Author

Hii @Waleed

as you say that [YOUR_Module_Name] here pass my module name but actually i don' t create any module i just inherited the crm.lead module so i can't understand what is pass there as a YOUR_Module_Name. can you say me what is pass there ?

YOUR_Module_Name means your your custom module name

Author

But i don't made any custom module. i just inherited the crm.lead system module. so what i do ?

Any customization or inheritance should be done custom module. what is the main folder name which contain your python ,XMl,init and manifest files?

Related Posts Replies Views Activity
1
Jun 23
1812
1
Mar 16
4239
1
Mar 15
4177
0
Nov 19
2691
3
Feb 18
8152