Hi,
I've placed a field.Selection
called Behavior
on Odoo Settings and I want the user to be able to select between three different speeds.
The field is working fine, but the speed values don't get stored or loaded properly.
I really don't know how to make the functions get_values
and set_values
work when using field.Selection
Can anyone help me?
With the code that I came up with the values get "stored" only until I refresh the page:
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
behavior = fields.Selection(string="Select the behavior",
selection=[('fast', 'As fast as possible'),
('normal', 'Normal speed'),
('slow', 'The slowest')],
required=False, default='fast')
def set_values(self):
super(ResConfigSettings, self).set_values()
self.env['ir.config_parameter'].sudo().set_param('my_app.behavior', self.behavior)
return
@api.model
def get_values(self):
res = super(ResConfigSettings, self).get_values()
res.update(
behavior = self.env['ir.config_parameter'].sudo().set_param('my_app.behavior', self.behavior) or "normal"
)
return res