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.

47 lines
2.1 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Author Guewen Baconnier. Copyright Camptocamp SA
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. ##############################################################################
  20. from osv import fields, osv
  21. from server_environment import serv_config
  22. class external_referential(osv.osv):
  23. _inherit = 'external.referential'
  24. def _get_environment_config_by_name(self, cr, uid, ids, field_names, arg, context):
  25. values = {}
  26. for referential in self.browse(cr, uid, ids, context):
  27. values[referential.id] = {}
  28. for field_name in field_names:
  29. section_name = '.'.join((self._name.replace('.', '_'), referential.name))
  30. value = serv_config.get(section_name, field_name)
  31. values[referential.id].update({field_name: value})
  32. return values
  33. _columns = {
  34. 'location': fields.function(_get_environment_config_by_name, type='char', size=200,
  35. method=True, string='Location', multi='connection_config'),
  36. 'apiusername': fields.function(_get_environment_config_by_name, type='char', size=64,
  37. method=True, string='User Name', multi='connection_config'),
  38. 'apipass': fields.function(_get_environment_config_by_name, type='char', size=64,
  39. method=True, string='Password', multi='connection_config'),
  40. }
  41. external_referential()