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

A boolean field created in res_users, if that boolean field is True for the user logged in, the Supplier menuitem Should be visible... if False need to hide the Suppliers Menu

Avatar
Discard
Best Answer

The visibility of menuitems is set via the groups tag.

You could add a group for your suppliers and use an on_change method to add or remove the group when the boolean field is changed.

XML snippets:

<menuitem name="supplier_menu" string="Supplier Menu" groups="my_model.supplier_group" action="menu_action"/>

<field name="is_supplier" on_change="onchange_is_supplier(is_supplier)"/>

.py:

def onchange_is_supplier(self, cr, uid, ids, is_supplier):
    supplier_group_id = self.pool.get('ir.model.data').get_object(cr, uid, 'my_model', 'supplier_group').id
    if is_supplier:
        result = {'value': {'groups_id': [(4, supplier_group_id)]}};
    else:   
        result = {'value': {'groups_id': [(3, supplier_group_id)]}};
    return result;

 

Regards.   

Avatar
Discard