Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Need to Hide Menu Item Based on the Field condition

By
Narayanamurthy
on 7/21/14, 3:14 AM 932 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

0

René Schuster

--René Schuster--
1560
| 5 5 8
Weinheim, Germany
--René Schuster--

Challenge Everything!

René Schuster
On 7/21/14, 4:27 AM

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.   

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/21/14, 3:14 AM
Seen: 932 times
Last updated: 6/23/15, 4:43 PM