I can install module already and i want to uninstall the module
I tried to use this:
boolean_field   = fields.Boolean('Install or Uninstall')
@api.onchange('
boolean_field
')
    def install_module_secondary(self):
        irModuleObj = self.env['ir.module.module']
        irModuleObj.update_list()
        moduleIds = irModuleObj.search(
                               [
                                ('state', '!=', 'installed'),
                                ('name', '=', 'module_name')
                               ]
                              )
          
        if moduleIds and self.boolean_field== True:
            moduleIds[0].button_immediate_install()
@api.onchange('
boolean_field
')
    def uninstall_module_secondary(self):
        irModuleObj = self.env['ir.module.module']
        irModuleObj.update_list()
        moduleIdsUninstall = irModuleObj.search(
                               [
                                ('state', '=', 'installed'),
('name', '=', 'module_name') 
                               ]
                              )
           
if moduleIdsUninstall and self.boolean_field== False: 
            moduleIdsUninstall[0].button_uninstall_wizard()
But it returns tuple index out of index then I removed the zero in uninstall then nothing happens, it just reload the page
