Přejít na obsah
Menu
You need to be registered to interact with the community.
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
Zrušit
Autor Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

Hi, 

You can see following for this:

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

Hope it helps,

Thanks

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
zář 22
2217
0
úno 21
2221
1
led 20
1404
2
bře 24
7674
1
pro 21
5402