Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
1604 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
ene 25
464
2
ago 24
807
0
abr 25
260
0
nov 24
586
0
oct 24
778