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.

38 lines
1.6 KiB

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