跳至內容
選單
此問題已被標幟

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:​

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
11月 19
60
7
5月 16
10258
1
3月 15
5186
2
8月 23
28588
3
4月 25
12059