Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
1681 Zobrazení

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?

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
led 25
511
2
srp 24
844
0
dub 25
335
0
lis 24
685
0
říj 24
866