Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1573 Lượt xem

if you are using odoo community and you want to calculate your employees salary based on their attendance using python code please refer the below code. 


result =(contract.wage/31) * sum(i.worked_hours for i in employee.attendance_ids)



Happy for improvement comment or if there are any other methods.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

This looks wrong, or incomplete. 

"employee.attendance_ids" contains ALL attendance data, and I'm sure this is NOT what you want.

You must always filter the data for the current month, or in alternative with an interval of your choice.
Eg: You pay every w week 
or 
When you pay on every 21st of the month, and the remaining days are paid in the next month (on the 21st). 

Possible fix:
Add a filter to the attendance_ids, so you only get the ones in the required interval and not ALL of them.

You can use Check IN to validate the time intervals


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

can you please provide the code for those you pay on monthly and weekly base ? it's good to share it

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 10 24
2007
1
thg 2 22
3689
1
thg 7 24
7487
0
thg 11 15
3968
0
thg 3 15
4751