res_config.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. # -*- coding: utf-8 -*-
  2. from openerp import api, models, fields
  3. from openerp.tools.safe_eval import safe_eval
  4. class ResConfig(models.TransientModel):
  5. _inherit = 'res.config.settings'
  6. image_type = fields.Selection(selection=[('small', 'Pequeña'), ('big', 'Grande')], default='small', string='Imagen', required=True)
  7. allow_currency_exchange = fields.Boolean(default=False, string='Permitir cambiar moneda')
  8. view_currency_exchanges = fields.Boolean(default=False, string='Permitir ver cambio de monedas')
  9. currency_ids = fields.Many2many('res.currency', string='Monedas')
  10. '''
  11. '''
  12. @api.multi
  13. def set_default_settings(self):
  14. ir_config = self.env['ir.config_parameter']
  15. ir_config.set_param('eiru_pos.image_type', str(self.image_type))
  16. ir_config.set_param('eiru_pos.allow_currency_exchange', repr(self.allow_currency_exchange))
  17. ir_config.set_param('eiru_pos.view_currency_exchanges', repr(self.view_currency_exchanges))
  18. ir_config.set_param('eiru_pos.currency_ids', repr(self.currency_ids.mapped(lambda x: x.id)))
  19. @api.model
  20. def get_default_settings(self, fields):
  21. ir_config = self.env['ir.config_parameter']
  22. res_currency = self.env['res.currency']
  23. return {
  24. 'image_type': ir_config.get_param('eiru_pos.image_type', 'small'),
  25. 'allow_currency_exchange': safe_eval(ir_config.get_param('eiru_pos.allow_currency_exchange', 'False')),
  26. 'view_currency_exchanges': safe_eval(ir_config.get_param('eiru_pos.view_currency_exchanges', 'False')),
  27. 'currency_ids': safe_eval(ir_config.get_param('eiru_pos.currency_ids', '[]'))
  28. }