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
1386 Widoki

Hello,

How are the leaves calculated for a new employee joining after the allocation of the leaves in the system?

To be more clear,

Let us say I am completing all the leave allocations by the beginning of January (including Accrual leaves). An employee joins in the month of February. Then how are the leaves calculated for this employee?

Will the system calculate it automatically based on the pervious created allocations?

Do we need to allocate the leaves again in the system?

Awatar
Odrzuć
Autor Najlepsza odpowiedź

The system was not automatically adding new employees created after the accrual allocations. So we created an automation rule (execute code) to add and allocate employees to the accrual system.

employee = record

employee_name = employee.name


current_year = datetime.date.today().year


leave_type = env['hr.leave.type'].browse(8) #8 is the id of the Leave or the Time Off Type

allocation_obj = env['hr.leave.allocation']

accrual_plan = env['hr.leave.accrual.plan'].browse(4) #4 is the id of the Accrual type created in the system


if leave_type:

    existing_allocation = allocation_obj.search([

        ('employee_id', '=', employee.id),

        ('holiday_status_id', '=', leave_type.id),

        ('state', '=', 'validate'),

        ('date_to', '=', f'{current_year}-12-31'),

    ], limit=1)

    if not existing_allocation:

        allocation_obj.create({

            'name': f'Emergency Leave Allocation for {employee_name} - {current_year}',

            'employee_id': employee.id,

            'holiday_status_id': leave_type.id,

            'allocation_type': 'accrual',

            'accrual_plan_id': accrual_plan.id,

            'number_of_days': 0,

            'date_from':datetime.date.today(),

        })


In this way, the new employees will be added and they will have the leaves created automatically based on the accrual configuration.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
lip 23
7091
1
sty 23
2313
1
mar 15
4243
3
lut 19
4044
0
cze 16
4034