hi all , i want to get values from a field which is in res config settings model and use it in another model
i have tried like this below method to get the values but , its not working
// my model :
class HolidaysAllocation(models.Model):
_inherit = "\hr\.leave\.allocation\"\\
\
\ \ \ \ _description\ \=\ \"Time\ Off\ Allocation\"\
\
\
\
\ \ \ \ \@api\.model\ \ \
\
\ \ \ \ def\ _get_values\(self\)\:\ \ \ \ \ \ \ \ \ \ \ \
\
\ \ \ \ \ \ \ \ res\ \=\ super\(HolidaysAllocation\,\ self\)\._get_values\(\)\ \ \ \ \ \ \ \
\
\ \ \ \ \ \ \ \ with_user\ \=\ self\.env\[\'ir\.config_parameter\'\]\.sudo\(\)\ \ \ \ \ \ \
\
\ \ \ \ \ \ \ \ inform_taking_leave_id\ \=\ \ with_user\.get_param\(\'inform_taking_leave\.res_ids\ \'\)\ \ \ \ \ \ \ \
\
\ \ \ \ \ \ \ \ res\.update\(res_inform_ids\=\[\(6\,\ 0\,\ literal_eval\(inform_taking_leave_id\)\)\]\ if\ inform_taking_leave_id\ else\ False\,\ \)\ \ \ \ \ \ \ \
\
\ \ \ \ \ \ \ \ return\ res\
\
\
\
\
\
\ \ \ \ res_inform_ids\ \=\ fields\.Many2many\(\'hr\.employee\'\,string\=\'Inform\ and\ Taking\ Leave\'\,\ help\=\'Inform\ and\ Taking\ Leave\'\,default\=_get_values\,\)\
\
\
\
\
\
\\\/\/\ res\ config\ field\ \\
class\ HrLeaveInform\(models\.TransientModel\)\:\
\
\ \ \ \ _inherit\ \=\ \'\res\.config\.settings\'\\
\
\
\
\ \ \ \ res_ids\ \=\ fields\.Many2many\(\'hr\.employee\'\)\
\
\ \
\
\ \ \ \ def\ set_values\(self\)\:\ \ \ \ \ \ \ \ \ \ \
\
\ \ \ \ \ \ \ \ res\ \=\ super\(HrLeaveInform\,\ self\)\.set_values\(\)\ \ \ \ \ \ \ \
\
\ \ \ \ \ \ \ \ self\.env\[\'ir\.config_parameter\'\]\.sudo\(\)\.set_param\(\'inform_taking_leave\.res_ids\'\,\ \self.res_ids.ids)
return res
@api.model
def get_values(self):
res = super(HrLeaveInform, self).get_values()
with_user = self.env['ir.config_parameter'].sudo()
inform_taking_leave_id = with_user.get_param('inform_taking_leave.res_ids')
res.update(res_ids=[(6, 0, literal_eval(inform_taking_leave_id))] if inform_taking_leave_id else False, )
return res
anyone