Merge pull request #2565 from expsa/Esraa-Ensan-hr-tasks
termination transfer by emp type
This commit is contained in:
commit
a04ece14cb
|
|
@ -870,42 +870,44 @@ 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': account,
|
||||
'account_id': item.account_debit_id.id,
|
||||
'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': account,
|
||||
'account_id': item.account_credit_id.id,
|
||||
'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': account,
|
||||
'account_id': item.account_debit_id.id,
|
||||
'partner_id': self.employee_id.user_id.partner_id.id})
|
||||
|
||||
for item in self.loans_ids:
|
||||
|
|
@ -1087,7 +1089,18 @@ 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', related='salary_rule_id.rule_credit_account_id',
|
||||
readonly=True, required=False)
|
||||
account_debit_id = fields.Many2one('account.account', related='salary_rule_id.rule_debit_account_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")
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue