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.

48 lines
2.1 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Author: Guewen Baconnier
  5. # Copyright 2011-2012 Camptocamp SA
  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 osv import fields, osv
  22. from server_environment import serv_config
  23. class external_referential(osv.osv):
  24. _inherit = 'external.referential'
  25. def _get_environment_config_by_name(self, cr, uid, ids, field_names, arg, context):
  26. values = {}
  27. for referential in self.browse(cr, uid, ids, context):
  28. values[referential.id] = {}
  29. for field_name in field_names:
  30. section_name = '.'.join((self._name.replace('.', '_'), referential.name))
  31. value = serv_config.get(section_name, field_name)
  32. values[referential.id].update({field_name: value})
  33. return values
  34. _columns = {
  35. 'location': fields.function(_get_environment_config_by_name, type='char', size=200,
  36. method=True, string='Location', multi='connection_config'),
  37. 'apiusername': fields.function(_get_environment_config_by_name, type='char', size=64,
  38. method=True, string='User Name', multi='connection_config'),
  39. 'apipass': fields.function(_get_environment_config_by_name, type='char', size=64,
  40. method=True, string='Password', multi='connection_config'),
  41. }
  42. external_referential()