# -*- coding: utf-8 -*- from openerp import api, models, fields class OdooManagementConfig(models.TransientModel): _inherit = 'res.config.settings' _name = 'odoo.management.config' field_types = ( ('docker_socket_path', 'char'), ('docker_exclusion_list', 'list'), ('odoo_docker_image', 'char'), ('odoo_network', 'char'), ('odoo_ports_range', 'list'), ('odoo_root_path', 'char'), ('odoo_db_link', 'char'), ('modules_git_path', 'char'), ) docker_socket_path = fields.Char(string='Socket', size=100, default='/var/run/docker.sock') docker_exclusion_list = fields.Char(string='Lista de exclusión', size=160) odoo_docker_image = fields.Char(string='Imagen docker', size=50) odoo_network = fields.Char(string='Red virtual', size=50, default='eiru') odoo_ports_range = fields.Char(string='Rango de puertos', size=50) odoo_root_path = fields.Char(string='Ruta raíz', size=50, default='/opt/odoo') odoo_db_link = fields.Char(string='Base de datos', size=50, default='db') modules_git_path = fields.Char(string='Ruta del repositorio', size=100, default='/opt/gogs/git/gogs-repositories') @api.multi def set_default_settings(self, values): ir_values_obj = self.env['ir.values'] types = dict(self.field_types) for v in values: value = None if types[v] == 'char': value = values[v] if types[v] == 'list': value = ','.join(map(lambda x: x.strip(), values[v])) value = value or '' ir_values_obj.set_default('odoo.instance', v, value) @api.model def get_default_settings(self, fields): ir_values = self.env['ir.values'].get_defaults_dict('odoo.instance') types = dict(self.field_types) defaults = {} for v in ir_values: value = None if types[v] == 'char': value = ir_values[v] if types[v] == 'list': value = filter(lambda x: x != '', ir_values[v].split(',')) defaults[v] = value or '' return defaults