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.

40 lines
1.2 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 odoo import api, models, tools
  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. @api.model
  10. @tools.ormcache('self.env.cr.dbname')
  11. def _auth_timeout_get_parameter_delay(self):
  12. return int(
  13. self.env['ir.config_parameter'].sudo().get_param(
  14. DELAY_KEY, 7200,
  15. )
  16. )
  17. @api.model
  18. @tools.ormcache('self.env.cr.dbname')
  19. def _auth_timeout_get_parameter_ignored_urls(self):
  20. urls = self.env['ir.config_parameter'].sudo().get_param(
  21. IGNORED_PATH_KEY, '',
  22. )
  23. return urls.split(',')
  24. @api.multi
  25. def write(self, vals):
  26. res = super(IrConfigParameter, self).write(vals)
  27. self._auth_timeout_get_parameter_delay.clear_cache(
  28. self.filtered(lambda r: r.key == DELAY_KEY),
  29. )
  30. self._auth_timeout_get_parameter_ignored_urls.clear_cache(
  31. self.filtered(lambda r: r.key == IGNORED_PATH_KEY),
  32. )
  33. return res