In hr.employee model, how can I calculate the computed field with amount field in hr.payslip.input and hr.payslip.line?
- Employees who completed more than 12 months,
- from model hr.payslip.input sum of Amount where input_type_id = 12 (Provident Fund) and from model hr.payslip.line sum of Amount where input_type_id = 26 (Leave Encashment) and plus both amount field's sum
- Then calculate 75% of final value
Wants to add through Settings -> Technical -> Models.
I tried below to check what I can do, but it's not working, definitely I am not a Python guy (background is Oracle) field x_loan_applicable_amount added in employee model.
def compute_loan_applicable_amount(self):
input_amt = self.env['hr.payslip.input']
for rec in self:
applicable_amount = 0
input_ids = input_amt.search([('payslip_id.employee_id', '=', rec.id)])
if input_ids:
for inputs in input_ids:
# amount = payment amount
applicable_amount += inputs.amount
rec['x_loan_applicable_amount'] = applicable_amount
kindly help.