Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
11406 Widoki

Hi all;

How to get the number of worked days in date period (for custom module)

ie, i have created_date and closing_date fields; I need to calculate the number of worked days between the created date and the closing date 

OR

need to get the number of holidays between the created_date and closing_date

and also need to get the working hours per day

Please help me to solve this ......

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

If you check the hr_payroll module you can see similar computations. Open the payslip form and change the Period From and To dates, then you can see days get computed in the One2many field. You can reuse the same function for your purpose.

The function name is get_worked_day_lines in this file : https://github.com/odoo/odoo/blob/12.0/addons/hr_payroll/models/hr_payslip.py

You can see this line,

work_data = contract.employee_id.get_work_days_data(day_from, day_to, calendar=contract.resource_calendar_id)

Thanks

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
sty 25
1372
1
maj 24
3194
2
gru 23
14675
0
paź 23
33
3
paź 23
788