Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
1610 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
0
Jan 25
468
2
Agu 24
811
0
Apr 25
268
0
Nov 24
614
0
Okt 24
802