Skip to Content
Menu
This question has been flagged

Hey i have a field in res.config.setting and i want it to store different values(using set_param) for different companies. I have tried company_dependent= True but doesn't seem to work. Here is my field

apply_ded = fields.Integer(string='Apply deduction after',
company_dependent=True, config_parameter='employee_late_check_in.apply_ded',check_company=True)

def set_values(self):
res = super(LateCheckinSettings, self).set_values()
self.env['ir.config_parameter'].sudo().set_param('apply_ded_4', self.apply_ded_4) return res
 Anyone?
Avatar
Discard
Author Best Answer

No worries i found the solution. You need to add a field in the res.company(make it invisible) and make res.config field related to company field(readonly=False) and then  you can configure values in res.config for each company. Record will be unique for each company. Here is the code

in res.company

apply_ded_4 = fields.Integer(string='Apply deduction after',default=4)
in res.config.settings


apply_ded_4 = fields.Integer(string='Apply deduction after',related="company_id.apply_ded_4",readonly=False,
config_parameter='employee_late_check_in.apply_ded_4')

def set_values(self):
res = super(LateCheckinSettings, self).set_values()
self.env['ir.config_parameter'].sudo().set_param('apply_ded_4', self.apply_ded_4)
return res
i  called the field in my wizard like
first_ded = self.company.apply_ded_4
company is my cmpany_id field in the wizard.

Hope it helps you.


Avatar
Discard
Best Answer

Hi, 

You can see following for this:

https://youtu.be/GkNgc-fZO-I

Hope it helps,

Thanks

Avatar
Discard
Related Posts Replies Views Activity
0
Sep 22
2181
0
Feb 21
2205
1
Jan 20
1404
2
Mar 24
7627
1
Dec 21
5384