跳至内容
菜单
此问题已终结
1 回复
600 查看

Please who can help me.

I have this function:

  def compute_n_1_info(self,cr,uid,payslip,context=None):
if tools['int'](payslip.date_from[5:7])==1:
value = {'assiette_irpp_anuel_reel_n_1': 0.0,
'irpp_reel_n_1': 0.0,
'cumul_brut_imp_reel_n_1': 0.0,
'cumul_retenue_source_n_1': 0.0,
}
else:
value = {'assiette_irpp_anuel_reel_n_1': 1,
'irpp_reel_n_1': 1,
'cumul_brut_imp_reel_n_1': 1,
'cumul_retenue_source_n_1': 1,
}

but i got an error (

   if tools['int'](payslip.date_from[5:7])==1:
TypeError: 'module' object has no attribute '__getitem__'

) and i didnt know how to resolve it. please help

形象
丢弃
最佳答案

if payslip and payslip.date_from and isinstance(payslip.date_from[5:7], int)  == 1:

perhaps :

from openert import tools

......

if payslip and payslip.date_from and tools['int'](payslip.date_from[5:7])==1:

形象
丢弃
相关帖文 回复 查看 活动
4
10月 16
30885
1
9月 15
3635
0
4月 15
462
2
4月 15
614
0
4月 15
428