Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3660 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
พ.ย. 19
60
7
พ.ค. 16
10484
1
มี.ค. 15
5374
2
ส.ค. 23
28976
hide menus "Apps" for specific users แก้ไขแล้ว
3
เม.ย. 25
12996