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.

54 lines
2.0 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. # This file is part of inactive_session_timeout, an Odoo module.
  4. #
  5. # Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
  6. #
  7. # inactive_session_timeout is free software: you can redistribute it
  8. # and/or modify it under the terms of the GNU Affero General Public License
  9. # as published by the Free Software Foundation, either version 3 of
  10. # the License, or (at your option) any later version.
  11. #
  12. # inactive_session_timeout is distributed in the hope that it will
  13. # be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the
  18. # GNU Affero General Public License
  19. # along with inactive_session_timeout.
  20. # If not, see <http://www.gnu.org/licenses/>.
  21. #
  22. ##############################################################################
  23. from openerp import models, api, tools, SUPERUSER_ID
  24. DELAY_KEY = 'inactive_session_time_out_delay'
  25. IGNORED_PATH_KEY = 'inactive_session_time_out_ignored_url'
  26. class IrConfigParameter(models.Model):
  27. _inherit = 'ir.config_parameter'
  28. @tools.ormcache(skiparg=0)
  29. def get_session_parameters(self, db):
  30. param_model = self.pool['ir.config_parameter']
  31. cr = self.pool.cursor()
  32. delay = False
  33. urls = []
  34. try:
  35. delay = int(param_model.get_param(
  36. cr, SUPERUSER_ID, DELAY_KEY, 7200))
  37. urls = param_model.get_param(
  38. cr, SUPERUSER_ID, IGNORED_PATH_KEY, '').split(',')
  39. finally:
  40. cr.close()
  41. return delay, urls
  42. @api.multi
  43. def write(self, vals, context=None):
  44. res = super(IrConfigParameter, self).write(vals)
  45. if self.key in [DELAY_KEY, IGNORED_PATH_KEY]:
  46. self.get_session_parameters.clear_cache(self)
  47. return res