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.

39 lines
1.6 KiB

  1. # -*- coding: utf-8 -*-
  2. import logging
  3. from ast import literal_eval
  4. from odoo import api, fields, models
  5. _logger = logging.getLogger(__name__)
  6. class ResConfigSettings(models.TransientModel):
  7. _inherit = 'res.config.settings'
  8. gogocarto_map_url = fields.Char(readonly=False)
  9. export_gogocarto_fields = fields.Many2many('ir.model.fields', 'export_field_rel', 'export_id', 'fields_id',
  10. domain="[""('model_id', '=', 'res.partner')\
  11. ,('name', 'not in', ('name','partner_longitude','partner_latitude'))""]",
  12. readonly=False)
  13. @api.model
  14. def get_values(self):
  15. res = super(ResConfigSettings, self).get_values()
  16. ICPSudo = self.env['ir.config_parameter'].sudo()
  17. gogocarto_map_url = ICPSudo.get_param('gogocarto_export_api.gogocarto_map_url')
  18. export_gogocarto_fields = ICPSudo.get_param('gogocarto_export_api.export_gogocarto_fields') if ICPSudo.get_param('gogocarto_export_api.export_gogocarto_fields') else "[]"
  19. res.update(
  20. gogocarto_map_url=gogocarto_map_url,
  21. export_gogocarto_fields= [(6, 0, literal_eval(export_gogocarto_fields))]
  22. )
  23. return res
  24. @api.multi
  25. def set_values(self):
  26. res = super(ResConfigSettings, self).set_values()
  27. ICPSudo = self.env['ir.config_parameter']
  28. ICPSudo.set_param('gogocarto_export_api.gogocarto_map_url',self.gogocarto_map_url)
  29. ICPSudo.set_param('gogocarto_export_api.export_gogocarto_fields',self.export_gogocarto_fields.ids)
  30. return res