res_config.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. allow_change_user = fields.Boolean(default=False, string='Permitir cambiar el usuario')
  10. allow_change_date = fields.Boolean(default=False, string='Permitir cambiar la fecha')
  11. allow_pricelist = fields.Boolean(default=False, string='Permitir tarifa de precios')
  12. currency_ids = fields.Many2many('res.currency', string='Monedas')
  13. '''
  14. '''
  15. @api.multi
  16. def set_default_settings(self):
  17. ir_config = self.env['ir.config_parameter']
  18. ir_config.set_param('eiru_pos.image_type', str(self.image_type))
  19. ir_config.set_param('eiru_pos.allow_currency_exchange', repr(self.allow_currency_exchange))
  20. ir_config.set_param('eiru_pos.view_currency_exchanges', repr(self.view_currency_exchanges))
  21. ir_config.set_param('eiru_pos.allow_change_user', repr(self.allow_change_user))
  22. ir_config.set_param('eiru_pos.allow_change_date', repr(self.allow_change_date))
  23. ir_config.set_param('eiru_pos.allow_pricelist', repr(self.allow_pricelist))
  24. ir_config.set_param('eiru_pos.currency_ids', repr(self.currency_ids.mapped(lambda x: x.id)))
  25. @api.model
  26. def get_default_settings(self, fields):
  27. ir_config = self.env['ir.config_parameter']
  28. return {
  29. 'image_type': ir_config.get_param('eiru_pos.image_type', 'small'),
  30. 'allow_currency_exchange': safe_eval(ir_config.get_param('eiru_pos.allow_currency_exchange', 'False')),
  31. 'view_currency_exchanges': safe_eval(ir_config.get_param('eiru_pos.view_currency_exchanges', 'False')),
  32. 'allow_change_user': safe_eval(ir_config.get_param('eiru_pos.allow_change_user', 'False')),
  33. 'allow_change_date': safe_eval(ir_config.get_param('eiru_pos.allow_change_date', 'False')),
  34. 'allow_pricelist': safe_eval(ir_config.get_param('eiru_pos.allow_pricelist', 'False')),
  35. 'currency_ids': safe_eval(ir_config.get_param('eiru_pos.currency_ids', '[]'))
  36. }