Help

inherit res.config.settings and save values from selection field

Closed
Avatar
Sugeesh Ps

The question has been closed for reason: Question / Code not indented

by
Sugeesh Ps
on 03/17/2020 06:29:13

HI, 

I have inherited res.config.settings and the view is rendered, but when i try to save the values i have met the error message like TypeError: set_param() missing 1 required positional argument: 'value'
here is my code :

class ResConfigSettings(models.TransientModel):

_inherit = "res.config.settings"

teeoff_time = fields.Boolean("Tee off Time Scheduling")

type = fields.Selection([
('by_golf_club', 'By Golf Club'),
('by_course', 'By Course')])

@api.model
def get_values(self):
res = super(ResConfigSettings, self).get_values()
res.update(
self.env['ir.config_parameter'].sudo().set_param('golf_management.type') or "by_golf_club"
)
return res

def set_values(self):
super(ResConfigSettings, self).set_values()
self.env['ir.config_parameter'].sudo().set_param('golf_management.type', self.type)

please help me to solve this...

3 Comments
Avatar
Discard
Avatar
Sehrish
-
Avatar
Niyas Raphy
-
1 Answer
6
Avatar
Mitul Shingala
Best Answer

Hello,

add @api.multi method decorator on set_values method.

@api.multi
def set_values(self):
    super(ResConfigSettings, self).set_values()
self.env['ir.config_parameter'].sudo().set_param('golf_management.type', self.type)

Avatar
Discard