콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
1654 화면

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.

아바타
취소
베스트 답변

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


아바타
취소
작성자 베스트 답변

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

아바타
취소
관련 게시물 답글 화면 활동
1
10월 24
2127
1
2월 22
3790
1
7월 24
7587
0
11월 15
4073
0
3월 15
4860