跳至內容
選單
此問題已被標幟
1 回覆
1688 瀏覽次數

I am trying multiply hourly wage and worked hours on the month but i get error. 

/ result = contract.hourly_wage * worked_days.WORK100.number_of_hours


Wrong python code defined for: - Employee: AHMET DEMİRAL - Contract: AHMET DEMİRAL 01122023 SÖZLEŞME - Payslip: Ücret Bordrosu - AHMET DEMİRAL - Haziran 2024 - Salary rule: Yevmiye Aylık Toplamı (YEVMIYE) - Error: : "'dict' object has no attribute 'WORK100'" while evaluating 'result = contract.hourly_wage * worked_days.WORK100.number_of_hours'


Is there any solve?

頭像
捨棄
最佳答案

Hello CAGATAY DINLER,


You encountered an error while trying to multiply the hourly wage with the number of hours worked in Odoo 17. The specific error message indicates an issue with accessing a dictionary key using dot notation, which is incorrect.


In Python, dictionaries do not support dot notation (e.g., worked_days.WORK100). Instead, dictionary values should be accessed using square brackets ([]) or the .get() method.


Dot notation is used for accessing attributes of objects, but since worked_days is a dictionary, this results in an AttributeError.


number_of_hours = worked_days['WORK100']['number_of_hours']

or you can use: number_of_hours = worked_days.get('WORK100', {}).get('number_of_hours', 0)


result = contract.hourly_wage * number_of_hours


Hope this Helps,

If you need any help in customization feel free to contact us.


Thanks & Regards,

Email:  odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
1月 25
512
2
8月 24
849
0
4月 25
337
0
11月 24
700
0
10月 24
880