# -*- coding: utf-8 -*- from openerp import api, models, fields from openerp.tools.safe_eval import safe_eval class ResConfig(models.TransientModel): _inherit = 'res.config.settings' image_type = fields.Selection(selection=[('small', 'Pequeña'), ('big', 'Grande')], default='small', string='Imagen', required=True) allow_currency_exchange = fields.Boolean(default=False, string='Permitir cambiar moneda') view_currency_exchanges = fields.Boolean(default=False, string='Permitir ver cambio de monedas') allow_change_user = fields.Boolean(default=False, string='Permitir cambiar el usuario') allow_change_date = fields.Boolean(default=False, string='Permitir cambiar la fecha') allow_pricelist = fields.Boolean(default=False, string='Permitir tarifa de precios') currency_ids = fields.Many2many('res.currency', string='Monedas') ''' ''' @api.multi def set_default_settings(self): ir_config = self.env['ir.config_parameter'] ir_config.set_param('eiru_pos.image_type', str(self.image_type)) ir_config.set_param('eiru_pos.allow_currency_exchange', repr(self.allow_currency_exchange)) ir_config.set_param('eiru_pos.view_currency_exchanges', repr(self.view_currency_exchanges)) ir_config.set_param('eiru_pos.allow_change_user', repr(self.allow_change_user)) ir_config.set_param('eiru_pos.allow_change_date', repr(self.allow_change_date)) ir_config.set_param('eiru_pos.allow_pricelist', repr(self.allow_pricelist)) ir_config.set_param('eiru_pos.currency_ids', repr(self.currency_ids.mapped(lambda x: x.id))) @api.model def get_default_settings(self, fields): ir_config = self.env['ir.config_parameter'] return { 'image_type': ir_config.get_param('eiru_pos.image_type', 'small'), 'allow_currency_exchange': safe_eval(ir_config.get_param('eiru_pos.allow_currency_exchange', 'False')), 'view_currency_exchanges': safe_eval(ir_config.get_param('eiru_pos.view_currency_exchanges', 'False')), 'allow_change_user': safe_eval(ir_config.get_param('eiru_pos.allow_change_user', 'False')), 'allow_change_date': safe_eval(ir_config.get_param('eiru_pos.allow_change_date', 'False')), 'allow_pricelist': safe_eval(ir_config.get_param('eiru_pos.allow_pricelist', 'False')), 'currency_ids': safe_eval(ir_config.get_param('eiru_pos.currency_ids', '[]')) }