Skip to Content
Menu
This question has been flagged
1 Reply
1462 Views

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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
0
Jan 25
411
2
Aug 24
713
0
Nov 24
517
0
Oct 24
652
1
Oct 24
1009