This question has been flagged
1 Reply
3676 Views

Hi all,

I've been going through the forum for this matter for a while now. The only solution provided is to obtain the number of unpaid leaves applied at the Leave module and translated into salary deduction at the Payroll module.

However, my situation is a bit different.

My employee could have forgotten to apply for an Unpaid leave which was supposed to be taken a month before. Once the Unpaid leave is applied, the current python code does not take into account the deduction from last month and this result in the wrong salary provided. 

This is the current code I'm using:

Conditions:
result=worked_days.Unpaid and worked_days.Unpaid.number_of_days or False

Computations:
result=-(contract.wage/26) * worked_days.Unpaid.number_of_days

This code works only if the Unpaid leave is taken in the same month before payroll is closed. I'm using Odoo 12 for Windows.

Please help.

Thanks in advance.
Avatar
Discard
Author Best Answer

Yes! Managed to get it to work. These are steps that I've taken:

  1. Create a salary rule. I call it Unpaid Leave

  2. Set the Conditions to be Always True

  3. At Computations, select Python Code. I use this: result=(inputs.UNPAID and + (inputs.UNPAID.amount))*(-contract.wage/26)

  4. Remember to include in the Input tab the appropriate information. In my case, I set Unpaid Leave as Description and UNPAID as Code.

Do give me a positive vote if it helps. Thanks =)

Avatar
Discard