-2

I made one drop-down list and now I want to show in this drop-down only which modules I have installed.

Only installed module's menus I want to show.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65

1 Answers1

0

Let me try to help you.

Firstly for your learning:

->Activate Debug mode.

->Then go to Apps.

->Select any App which you want.

->Go to Module Info.

->Place your pointer at any field which are visible in front of you.

->It will give you detail of model in which all modules which are installed or not installed are placed.

Secondly for sake of answer:

-> installed_modules = self.env['ir.module.module'].search([('state', '=', 'installed')])

->Then do whatever you want.

Adam Strauss
  • 1,889
  • 2
  • 15
  • 45
  • Hello, when i perform installed_modules field in function that time like this error are occurred. installed_modules_id = self.env['ir.module.module'].search([('state', '=', 'installed')]) NameError: name 'self' is not defined – Kiran Patil Nov 07 '19 at 06:13
  • Please share your code. Secondly i want to say 'Self' only exist when you are running code inside a class method. – Adam Strauss Nov 07 '19 at 06:17
  • class HideMenus(models.Model): _inherit = 'res.users' _rec_name = 'hide_menus' hide_menus = fields.Many2many(comodel_name="ir.ui.menu") installed_modules_id = self.env['ir.module.module'].search([('state', '=', 'installed')]) @api.multi def write(self, vals): res = super(HideMenus, self).write(vals) for rec in self: if u'hide_menus' in vals and rec.hide_menus: for est_rec in rec.hide_menus: – Kiran Patil Nov 07 '19 at 06:22
  • print("=============== Hide Menus ==============", est_rec.name) print("=========== installed modules ============", self.installed_modules_id.category_id) – Kiran Patil Nov 07 '19 at 06:22
  • You cannot use self when defining class properties. – Adam Strauss Nov 07 '19 at 06:22
  • Where you want to use installed_module_id? – Adam Strauss Nov 07 '19 at 06:42
  • installed_modules = self.env['ir.module.module'].search([('state', '=', 'installed')]) use this in your write method – Adam Strauss Nov 07 '19 at 06:48
  • after for loop. 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. – Kiran Patil Nov 07 '19 at 06:51
  • No problem :) thanks for you given efforts behind me – Kiran Patil Nov 07 '19 at 07:14