İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
7745 Görünümler

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
Vazgeç
En İyi Yanıt

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
Vazgeç
Üretici

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

Üretici

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?

İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Haz 23
3310
1
Mar 16
5007
1
Mar 15
5132
0
Kas 19
3497
3
Şub 18
9240