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

I created my own custom module named as Advance payment.It have a field called Advance Payment Amount and i store different values for different employee's.i need to get that field value from my custom module to the salary rule result.

Field: advancepay

Object: hr.advance.pay

I tried "result = advance.pay.advancepay" in rules configuration.But its not working

 

Avatar
Discard
Best Answer

Create field `advancepay` either in `hr.employee` or in `hr.contract`, then you can access it in `hr.salary.rule` model, like  `result = contract.advancepay`. Because object of `hr.advance.pay` model is not available in `hr.salary.rule`. These are the objects available:

     # Available variables:

     #----------------------

     # payslip: object containing the payslips

     # employee: hr.employee object

     # contract: hr.contract object

     # rules: object containing the rules code (previously computed)

     # categories: object containing the computed salary rule categories (sum of amount of all rules belonging to that category).

     # worked_days: object containing the computed worked days.

     # inputs: object containing the computed inputs.

     # Note: returned value have to be set in the variable 'result'

Avatar
Discard
Best Answer

Extend the fonction _get_payslip_lines under hr_payroll/models/hr_payslip.py

replace line localdict = dict(baselocaldict, employee=employee, contract=contract) by localdict = dict(baselocaldict, employee=employee, contract=contract, advancepay=contract.advancepay) and use advancepay as use employee.

Avatar
Discard