res_config.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # BizzAppDev
  5. # Copyright (C) 2015-TODAY bizzappdev(<http://www.bizzappdev.com>).
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # 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 GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. from openerp.osv import fields, osv
  22. from openerp.tools import config
  23. class project_configuration(osv.TransientModel):
  24. _inherit = 'base.config.settings'
  25. _columns = {
  26. 'test': fields.boolean('Active Test Mode'),
  27. 'develop': fields.boolean('Active Develop Mode'),
  28. }
  29. def get_default_test(self, cr, uid, ids, context=None):
  30. test = config.get('test', {}).get(cr.dbname, False)
  31. return {'test': test or False}
  32. def get_default_develop(self, cr, uid, ids, context=None):
  33. develop = config.get('develop', {}).get(cr.dbname, False)
  34. return {'develop': develop or False}
  35. def set_develop(self, cr, uid, ids, context=None):
  36. if not config.get('develop'):
  37. config['develop'] = {}
  38. config_parameters = self.pool.get("ir.config_parameter")
  39. for record in self.browse(cr, uid, ids, context=context):
  40. config['develop'][cr.dbname] = record.develop
  41. config_parameters.set_param(
  42. cr, uid, "develop", record.develop or '',
  43. context=context)
  44. def set_test(self, cr, uid, ids, context=None):
  45. if not config.get('test'):
  46. config['test'] = {}
  47. config_parameters = self.pool.get("ir.config_parameter")
  48. for record in self.browse(cr, uid, ids, context=context):
  49. config['test'][cr.dbname] = record.test
  50. config_parameters.set_param(
  51. cr, uid, "test", record.test or '',
  52. context=context)
  53. # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: