Skip to Content
Menu
This question has been flagged

Hi Community,

actually what i want suppose i created one field in user creation form and it's name is [hide_menus] and i store all menus in it. now i select the menus from hide_menus field and compare with [installed_modules_id] if menus are will match then this menu will be hide for user.so how to hide menu if you know please let me know.

See my Code

class HideMenus(models.Model):
    _inherit = 'res.users'
    _rec_name = 'hide_menus'

    hide_menus = fields.Many2many(comodel_name="ir.ui.menu")

    @api.multi
    def write(self, vals):
        installed_modules = self.env['ir.module.module'].search([('state', '=', 'installed'),('application', '=', True)])
        for instd in installed_modules:
            res = super(HideMenus, self).write(vals)
                print("===========   installed modules ============", instd.category_id.name)
                for rec in self:
                    if u'hide_menus' in vals and rec.hide_menus:
                        for est_rec in rec.hide_menus:
                            print("=============== Hide Menus ==============", est_rec.name)
                            if instd.category_id.name == est_rec.name:​

Avatar
Discard
Related Posts Replies Views Activity
0
Nov 19
60
7
May 16
8820
1
Mar 15
4326
2
Aug 23
26562
3
Aug 24
5533