You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.4 KiB

  1. # -*- coding: utf-8 -*-
  2. # (c) 2015 ACSONE SA/NV, Dhinesh D
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp import models, api, tools, SUPERUSER_ID
  5. DELAY_KEY = 'inactive_session_time_out_delay'
  6. IGNORED_PATH_KEY = 'inactive_session_time_out_ignored_url'
  7. class IrConfigParameter(models.Model):
  8. _inherit = 'ir.config_parameter'
  9. @tools.ormcache('db')
  10. def get_session_parameters(self, db):
  11. param_model = self.pool['ir.config_parameter']
  12. cr = self.pool.cursor()
  13. delay = False
  14. urls = []
  15. try:
  16. delay = int(param_model.get_param(
  17. cr, SUPERUSER_ID, DELAY_KEY, 7200))
  18. urls = param_model.get_param(
  19. cr, SUPERUSER_ID, IGNORED_PATH_KEY, '').split(',')
  20. finally:
  21. cr.close()
  22. return delay, urls
  23. def _auth_timeout_get_parameter_delay(self):
  24. delay, urls = self.get_session_parameters(self.pool.db_name)
  25. return delay
  26. def _auth_timeout_get_parameter_ignoredurls(self):
  27. delay, urls = self.get_session_parameters(self.pool.db_name)
  28. return urls
  29. @api.multi
  30. def write(self, vals, context=None):
  31. res = super(IrConfigParameter, self).write(vals)
  32. if self.key == DELAY_KEY:
  33. self.get_session_parameters.clear_cache(self)
  34. elif self.key == IGNORED_PATH_KEY:
  35. self.get_session_parameters.clear_cache(self)
  36. return res