콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
2523 화면

When I try to execute multiple slips for the same structure, If any of the rules uses the employee variable it raises an error saying that the variable is a recordset of more than one value. (The variable is holding the value of all the employees which payslip is being calculated).

Does someone know if this is a bug or am I doing something wrong?

This is the code of the rule:

result = result_rules.DDVM['total'] * (employee.holidays_accrued / 30)

The holidays_accrued is a field I added to the hr.employee model.

This is the error:

Wrong python code defined for salary rule Pago por Disfrute Vacacional (PDDVM). Error: : "Expected singleton: hr.employee(2, 3, 4, 5)" while evaluating "\nresult = result_rules.DDVM['total'] * (employee.holidays_accrued / 30)\n 

I also checked for the code on the hr_payroll module and both in the compute_rule and in the get_local_dict it is written so it works with each rule. (Which makes me wonder were it's getting the recordset value for the employee that is showing to me in the error).

Any help would be appreciated, thanks!

아바타
취소
베스트 답변

Hi Miguel Gozaine,

Can you please share the detail of the "holiday_accrued" field and its type for analysing this issue.

Thanks

아바타
취소
작성자 베스트 답변

Hello Malay. This is the definition of the field:

holidays_accrued = fields.Float(compute="_compute_holidays_accrued")

And this is the compute:

@api.depends("contract_id.salary_type")     def _compute_holidays_accrued(self):         for employee in self:             salary_type = employee.contract_id.salary_type             employee.holidays_accrued = 0             if type(employee.id) == int:                 employee_salary_payments = employee.get_all_payroll_moves()                 if salary_type and employee_salary_payments:                     if salary_type == "fixed":                         employee.holidays_accrued = employee_salary_payments[-1]["total_accrued"]                     else:                         last_month_accrued = employee_salary_payments[-1]["total_accrued"]                         second_to_last_month_accrued = (                             employee_salary_payments[-2]["total_accrued"]                             if len(employee_salary_payments) > 1                             else 0                         )                         third_to_last_month_accrued = (                             employee_salary_payments[-3]["total_accrued"]                             if len(employee_salary_payments) > 2                             else 0                         )                          employee.holidays_accrued = (                             last_month_accrued                             + second_to_last_month_accrued                             + third_to_last_month_accrued                         ) / 3


아바타
취소
관련 게시물 답글 화면 활동
1
7월 25
2509
2
7월 25
7950
2
7월 25
4388
2
7월 25
4098
2
6월 25
2693