This commit is contained in:
Bakry 2025-05-18 17:13:03 +03:00
parent 88be5d0bbc
commit 2604bd548d
1 changed files with 16 additions and 6 deletions

View File

@ -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