Skip to Content
Menu
This question has been flagged
2 Replies
3757 Views

Odoo Payroll by default pays allowance in full, even if there are unpaid days for the employee.

In our company we have one allowance "Other Allowances" which is payable only for the days worked.

Wondering if you can suggest the Python Code to this effect.

( to replace:
 result = contract.l10n_ae_other_allowances)

Thanks 

Avatar
Discard
Best Answer

Hi,

Try,



***********************************************************************************

UPDATE

Since the 'Other Allowance' is a monthly amount and not calculated on a daily basis, We need to convert the amount to a daily rate and then multiply it by the number of days worked.


For your Second Concern, You can choose the 'WORKED ENTRIES' that need to be deducted from the actual worked days.


Let's create two new fields named 'x_days' and 'x_actual_days'.


To do this from Odoo UI, Activate Developer Mode,


Go to Settings > Technical > Database Structure > Fields

Create the field x_days, 
This field will compute the total number of days in the month 



Create the second field x_actual_days,
This field will compute the total number of days the employee worked.



Goto Employee Payslip, Click on Edit View Form and add those fields in the view.





Save the record, You will see that two fields have been added.



Here, the payslip was created for the month of August. Thus, the total number of days is 31. 

The employee took a Generic Time Off (with the code LEAVE100), and in the compute function of the 'x_actual_days' field, we deducted this time off. As a result, the actual number of days worked is 30.

Now Goto Salary Rule and Update the Python expression,


nb: x_studio_other_allowance is the custom field I created in the contract.

For example, the employee 'Jeffrey Kelly's other allowance is 310 per month



In this case, we deduct the amount for the day on which the employee took a 'Generic Time Off.' As a result, the actual number of working days becomes 30.

The calculation will be (310/31) * 30 = 300.





Hope it helps,
Kiran K

Avatar
Discard
Author

Hi Kiran thanks for the support.
The code works....partially
Since the "Other Allowance" is a monthly number not daily, the final result is the allowance multiplied by the number of days.
Secondly, if the employee is on Sick Leave or any other Paid Leave, even then the allowance is deducted.
Really appreciate your support.
Thanks

Author

Thanks for input
Finally i got it solved
result = (payslip.paid_amount/contract.wage)*contract.l10n_ae_other_allowances

I'm glad to hear that your issue has been resolved. Regarding the calculation, I don't quite understand how the amount is determined based on the number of days worked.

Please take a look at my updated answer, which tackles the two concerns you mentioned.

Thanks :)

Author

Thanks Kiran
Regarding the other approach:
Basic Salary Paid calculates the ratio of "days paid/total number of days"
We multiply this with the "allowance" to arrive the net allowance payable

Best Answer

You can customize salary rule for this case:


if #condition:
​result = contract.l10n_ae_other_allowances
else:
​... ​
Avatar
Discard
Author

Can you please suggest the complete python code.

I am not a developer, just a User, thanks

Can you provide for me your URL or database? I will support the complete python code.

Author

Thanks for your input
Finally i got is solved
result = (payslip.paid_amount/contract.wage)*contract.l10n_ae_other_allowances

Related Posts Replies Views Activity
1
Feb 24
852
1
Dec 23
732
1
Mar 25
323
0
Feb 25
420
1
Dec 24
1014