parameters: (cls, cr, jobs)
docstring: Ensure no module is installing or upgrading
docstring_summary: Ensure no module is installing or upgrading
docstring_tokens: Ensure no module is installing or upgrading
function: def _check_modules_state(cls, cr, jobs):
          """ Ensure no module is installing or upgrading """
          cr.execute("""
              SELECT COUNT(*)
              FROM ir_module_module
              WHERE state LIKE %s
          """, ['to %'])
          (changes,) = cr.fetchone()
          if not changes:
              return
  
          if not jobs:
              raise BadModuleState()
  
          oldest = min([
              fields.Datetime.from_string(job['nextcall'])
              for job in jobs
          ])
          if datetime.now() - oldest < MAX_FAIL_TIME:
              raise BadModuleState()
  
          # the cron execution failed around MAX_FAIL_TIME * 60 times (1 failure
          # per minute for 5h) in which case we assume that the crons are stuck
          # because the db has zombie states and we force a call to
          # reset_module_states.
          odoo.modules.reset_modules_state(cr.dbname)
function_tokens: def _check_modules_state ( cls , cr , jobs ) : cr . execute ( """
              SELECT COUNT(*)
              FROM ir_module_module
              WHERE state LIKE %s
          """ , [ 'to %' ] ) ( changes , ) = cr . fetchone ( ) if not changes : return if not jobs : raise BadModuleState ( ) oldest = min ( [ fields . Datetime . from_string ( job [ 'nextcall' ] ) for job in jobs ] ) if datetime . now ( ) - oldest < MAX_FAIL_TIME : raise BadModuleState ( ) # the cron execution failed around MAX_FAIL_TIME * 60 times (1 failure # per minute for 5h) in which case we assume that the crons are stuck # because the db has zombie states and we force a call to # reset_module_states. odoo . modules . reset_modules_state ( cr . dbname )