|
|
@ -1,4 +1,4 @@ |
|
|
|
#-*- coding:utf-8 -*- |
|
|
|
# -*- coding:utf-8 -*- |
|
|
|
|
|
|
|
from odoo import api, fields, models, _ |
|
|
|
from odoo.exceptions import UserError |
|
|
@ -23,13 +23,16 @@ class HrPayslipLine(models.Model): |
|
|
|
return partner_id |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
class HrPayslip(models.Model): |
|
|
|
_inherit = 'hr.payslip' |
|
|
|
|
|
|
|
date = fields.Date('Date Account', states={'draft': [('readonly', False)]}, readonly=True, |
|
|
|
help="Keep empty to use the period of the validation(Payslip) date.") |
|
|
|
help="Keep empty to use the period of the validation(Payslip) date.") |
|
|
|
journal_id = fields.Many2one('account.journal', 'Salary Journal', readonly=True, required=True, |
|
|
|
states={'draft': [('readonly', False)]}, default=lambda self: self.env['account.journal'].search([('type', '=', 'general')], limit=1)) |
|
|
|
states={'draft': [('readonly', False)]}, |
|
|
|
default=lambda self: self.env['account.journal'].search([('type', '=', 'general')], |
|
|
|
limit=1)) |
|
|
|
move_id = fields.Many2one('account.move', 'Accounting Entry', readonly=True, copy=False) |
|
|
|
|
|
|
|
@api.model |
|
|
@ -41,7 +44,8 @@ class HrPayslip(models.Model): |
|
|
|
@api.onchange('contract_id') |
|
|
|
def onchange_contract(self): |
|
|
|
super(HrPayslip, self).onchange_contract() |
|
|
|
self.journal_id = self.contract_id.journal_id.id or (not self.contract_id and self.default_get(['journal_id'])['journal_id']) |
|
|
|
self.journal_id = self.contract_id.journal_id.id or ( |
|
|
|
not self.contract_id and self.default_get(['journal_id'])['journal_id']) |
|
|
|
|
|
|
|
def action_payslip_cancel(self): |
|
|
|
moves = self.mapped('move_id') |
|
|
@ -87,7 +91,6 @@ class HrPayslip(models.Model): |
|
|
|
}) |
|
|
|
line_ids.append(debit_line) |
|
|
|
debit_sum += debit_line[2]['debit'] - debit_line[2]['credit'] |
|
|
|
|
|
|
|
if credit_account_id: |
|
|
|
credit_line = (0, 0, { |
|
|
|
'name': line.name, |
|
|
@ -106,7 +109,8 @@ class HrPayslip(models.Model): |
|
|
|
if currency.compare_amounts(credit_sum, debit_sum) == -1: |
|
|
|
acc_id = slip.journal_id.default_credit_account_id.id |
|
|
|
if not acc_id: |
|
|
|
raise UserError(_('The Expense Journal "%s" has not properly configured the Credit Account!') % (slip.journal_id.name)) |
|
|
|
raise UserError(_('The Expense Journal "%s" has not properly configured the Credit Account!') % ( |
|
|
|
slip.journal_id.name)) |
|
|
|
adjust_credit = (0, 0, { |
|
|
|
'name': _('Adjustment Entry'), |
|
|
|
'partner_id': False, |
|
|
@ -121,7 +125,8 @@ class HrPayslip(models.Model): |
|
|
|
elif currency.compare_amounts(debit_sum, credit_sum) == -1: |
|
|
|
acc_id = slip.journal_id.default_debit_account_id.id |
|
|
|
if not acc_id: |
|
|
|
raise UserError(_('The Expense Journal "%s" has not properly configured the Debit Account!') % (slip.journal_id.name)) |
|
|
|
raise UserError(_('The Expense Journal "%s" has not properly configured the Debit Account!') % ( |
|
|
|
slip.journal_id.name)) |
|
|
|
adjust_debit = (0, 0, { |
|
|
|
'name': _('Adjustment Entry'), |
|
|
|
'partner_id': False, |
|
|
@ -142,20 +147,25 @@ class HrPayslip(models.Model): |
|
|
|
class HrSalaryRule(models.Model): |
|
|
|
_inherit = 'hr.salary.rule' |
|
|
|
|
|
|
|
analytic_account_id = fields.Many2one('account.analytic.account', 'Analytic Account') |
|
|
|
account_tax_id = fields.Many2one('account.tax', 'Tax') |
|
|
|
account_debit = fields.Many2one('account.account', 'Debit Account', domain=[('deprecated', '=', False)]) |
|
|
|
account_credit = fields.Many2one('account.account', 'Credit Account', domain=[('deprecated', '=', False)]) |
|
|
|
analytic_account_id = fields.Many2one('account.analytic.account', 'Analytic Account', help="Analytic account") |
|
|
|
account_tax_id = fields.Many2one('account.tax', 'Tax', help="Tax account") |
|
|
|
account_debit = fields.Many2one('account.account', 'Debit Account', help="Debit account", domain=[('deprecated', '=', False)]) |
|
|
|
account_credit = fields.Many2one('account.account', 'Credit Account', help="CRedit account", domain=[('deprecated', '=', False)]) |
|
|
|
|
|
|
|
|
|
|
|
class HrContract(models.Model): |
|
|
|
_inherit = 'hr.contract' |
|
|
|
_description = 'Employee Contract' |
|
|
|
|
|
|
|
analytic_account_id = fields.Many2one('account.analytic.account', 'Analytic Account') |
|
|
|
journal_id = fields.Many2one('account.journal', 'Salary Journal') |
|
|
|
analytic_account_id = fields.Many2one('account.analytic.account', 'Analytic Account', help="Analytic account") |
|
|
|
journal_id = fields.Many2one('account.journal', 'Salary Journal', help="Journal") |
|
|
|
|
|
|
|
|
|
|
|
class HrPayslipRun(models.Model): |
|
|
|
_inherit = 'hr.payslip.run' |
|
|
|
|
|
|
|
journal_id = fields.Many2one('account.journal', 'Salary Journal', states={'draft': [('readonly', False)]}, readonly=True, |
|
|
|
required=True, default=lambda self: self.env['account.journal'].search([('type', '=', 'general')], limit=1)) |
|
|
|
journal_id = fields.Many2one('account.journal', 'Salary Journal', states={'draft': [('readonly', False)]}, |
|
|
|
readonly=True, |
|
|
|
required=True, help="journal", |
|
|
|
default=lambda self: self.env['account.journal'].search([('type', '=', 'general')], |
|
|
|
limit=1)) |
|
|
|