Merge pull request #2561 from expsa/Esraa-Ensan-hr-tasks

termination transfer by emp type
This commit is contained in:
Esraa-Exp 2025-03-04 08:13:55 +02:00 committed by GitHub
commit c3dad968ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 18 deletions

View File

@ -870,44 +870,42 @@ class HrTermination(models.Model):
def pay(self):
line_vals = []
emp_type = self.employee_id.employee_type_id.id
for item in self.allowance_deduction_ids:
# check if amount greater than 0.0 to fill move account lines
if item.amount > 0.0:
# check for deduction credit account
if item.category_id.rule_type == 'deduction':
if not item.account_credit_id:
raise exceptions.Warning(
_('Undefined credit account for salary rule %s.') % (item.salary_rule_id.name))
# check for allowance debit account
elif item.category_id.rule_type == 'allowance':
if not item.account_debit_id:
raise exceptions.Warning(
_('Undefined debit account for salary rule %s.') % (item.salary_rule_id.name))
else:
if not item.account_debit_id:
raise exceptions.Warning(_('Check account debit for salary rule "%s" ') % (
item.salary_rule_id.name))
# fill move lines with allowance deduction
amount = round(item.amount,2)
if item.category_id.rule_type == 'allowance':
account = item.salary_rule_id.get_debit_account_id(emp_type)
if not account:
raise exceptions.Warning(
_('Sorry The Allowance %s is Not account Set') % item.salary_rule_id.name)
line_vals.append({
'name': ('Employee %s allowance.') % (self.employee_id.name),
'debit': abs(amount),
'account_id': item.account_debit_id.id,
'account_id': account,
'partner_id': self.employee_id.user_id.partner_id.id})
elif item.category_id.rule_type == 'deduction':
account = item.salary_rule_id.get_credit_account_id(emp_type)
if not account:
raise exceptions.Warning(
_('Sorry The Deduction %s is Not account Set') % item.salary_rule_id.name)
line_vals.append({
'name': ('Employee %s deduction.') % (self.employee_id.name),
'credit': abs(amount),
'account_id': item.account_credit_id.id,
'account_id': account,
'partner_id': self.employee_id.user_id.partner_id.id})
else:
account = item.salary_rule_id.get_debit_account_id(emp_type)
if not account:
raise exceptions.Warning(
_('Sorry The Allowance %s is Not account Set') % item.salary_rule_id.name)
line_vals.append({
'name': ('Employee %s rule.') % (self.employee_id.name),
'debit': abs(amount),
'account_id': item.account_debit_id.id,
'account_id': account,
'partner_id': self.employee_id.user_id.partner_id.id})
for item in self.loans_ids: