From 2604bd548de331b37abe37d699968103042c3ef5 Mon Sep 17 00:00:00 2001 From: Bakry Date: Sun, 18 May 2025 17:13:03 +0300 Subject: [PATCH] fix term --- .../hr_termination/models/hr_termination.py | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/odex25_hr/hr_termination/models/hr_termination.py b/odex25_hr/hr_termination/models/hr_termination.py index ab95cd782..beab77126 100644 --- a/odex25_hr/hr_termination/models/hr_termination.py +++ b/odex25_hr/hr_termination/models/hr_termination.py @@ -603,6 +603,7 @@ class HrTermination(models.Model): # Compute total allowance ,deduction ,loans and net self._leave_balance() self._compute_deduction_allowance_total() + self.allowance_deduction_ids.get_account_ids() # default loans lines @api.onchange('employee_id') @@ -1091,16 +1092,25 @@ class HrSalaryRuleAndLoansLines(models.Model): salary_rule_id = fields.Many2one('hr.salary.rule') category_id = fields.Many2one('hr.salary.rule.category', related='salary_rule_id.category_id', readonly=True, required=False) - account_credit_id = fields.Many2one('account.account', - readonly=True, required=False, compute="_get_accounts") - account_debit_id = fields.Many2one('account.account', readonly=True, - required=False, compute="_get_accounts") + account_credit_id = fields.Many2one('account.account', required=False,store=True) + account_debit_id = fields.Many2one('account.account', required=False,store=True) - def _get_accounts(self): + '''def _get_accounts(self): for rec in self: emp_type = rec.allowance_deduction_inverse_id.employee_id.employee_type_id.id rec.account_credit_id = rec.salary_rule_id.get_credit_account_id(emp_type) - rec.account_debit_id = rec.salary_rule_id.get_debit_account_id(emp_type) + rec.account_debit_id = rec.salary_rule_id.get_debit_account_id(emp_type)''' + + #get acoount IDs base on salary rule config + def get_account_ids(self): + for rec in self: + emp_type = rec.allowance_deduction_inverse_id.employee_id.employee_type_id + if rec.category_id.rule_type=='allowance': + account_debit = rec.salary_rule_id.get_debit_account_id(emp_type) + rec.account_debit_id = account_debit.id + if rec.category_id.rule_type=='deduction': + account_credit = rec.salary_rule_id.get_credit_account_id(emp_type) + rec.account_credit_id = account_credit.id