コンテンツへスキップ
メニュー
この質問にフラグが付けられました

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?
アバター
破棄
著作者 最善の回答

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.


アバター
破棄
最善の回答

Hi, 

You can see following for this:

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

Hope it helps,

Thanks

アバター
破棄
関連投稿 返信 ビュー 活動
0
9月 22
2323
0
2月 21
2269
1
1月 20
1404
2
3月 24
7756
1
12月 21
5475