Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

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?
Awatar
Odrzuć
Autor Najlepsza odpowiedź

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.


Awatar
Odrzuć
Najlepsza odpowiedź

Hi, 

You can see following for this:

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

Hope it helps,

Thanks

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
wrz 22
2222
0
lut 21
2224
1
sty 20
1404
2
mar 24
7684
1
gru 21
5414