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

I am using openerp 7 in Hospital. Basically each doctor is allowed to create a quotation. In order to do this, I have the following access rights for a doctor.


Sales : See All Leads

Accounting : Accountant

Purchases : User


To me, the last two access rights (Accounting and Purchases) are not actually meant to be assigned to the doctor. However

1. Creating quotation and adding sale line items will not work if the user is not assigned with Purchases : User or Warehouse : User. Either Purchase or Warehouse should be invisible to doctor, I dont want a doctor mingle with the product price.

2.  Doctor does not need to know about accounting as well.


I intend to make the Accounting, Purchase or Warehouse invisible when a doctor logins to the system. Is this possible ? How can I do this ? 

Or is there better way ? 

Avatar
Discard
Best Answer

You can override function `_filter_visible_menus` in ir.ui.menu model to invisible menu which you want

Ex:

def _filter_visible_menus(self, cr, uid, ids, context=None):
        res = super(ir_ui_menu, self)._filter_visible_menus(cr, uid, ids, context=context)
        user_pool = self.pool['res.users']
        context = context or {}
        menu_invis_ids = []
        if uid != 1:
            if user_pool.has_group(cr, uid, 'your_module.group_doctor') :
                menu_invis_ids += [menu_invisible_id1, menu_invisible_id2]
        if menu_invis_ids:
                for menu_id in menu_invis_ids:
                    if menu_id in res:
                        res.remove(menu_id)
        return res
Avatar
Discard
Author

Is using the code above the only way ? I notice there's 'your_module.group_doctor' line in the code. Do I need to create my own module or using the existing one ? and how do I create this 'group_doctor' ?

Related Posts Replies Views Activity
2
May 22
31135
1
Oct 19
3796
0
Mar 19
2685
0
Jan 19
3632
3
Dec 18
5355