[IMP] hr_payroll_account: Include employee's contract analytic account

If the employee's contract has an analytic account it should be considered for the payroll.
This is actually the way analytic accounts are meant to be used in the payroll, to segregate
information based on specific groups of employees or departments.

This does not override the default behavior, it just uses the analytic account on the
contract if it has it and the salary rule doesn't.

Ticket #1927941
Closes #30119

closes odoo/odoo#30491
This commit is contained in:
Robot Odoo
2019-01-24 14:29:16 +01:00
committed by GitHub
2 changed files with 4 additions and 2 deletions
@@ -85,7 +85,7 @@ class HrPayslip(models.Model):
'date': date,
'debit': amount > 0.0 and amount or 0.0,
'credit': amount < 0.0 and -amount or 0.0,
'analytic_account_id': line.salary_rule_id.analytic_account_id.id,
'analytic_account_id': line.salary_rule_id.analytic_account_id.id or slip.contract_id.analytic_account_id.id,
'tax_line_id': line.salary_rule_id.account_tax_id.id,
})
line_ids.append(debit_line)
@@ -100,7 +100,7 @@ class HrPayslip(models.Model):
'date': date,
'debit': amount < 0.0 and -amount or 0.0,
'credit': amount > 0.0 and amount or 0.0,
'analytic_account_id': line.salary_rule_id.analytic_account_id.id,
'analytic_account_id': line.salary_rule_id.analytic_account_id.id or slip.contract_id.analytic_account_id.id,
'tax_line_id': line.salary_rule_id.account_tax_id.id,
})
line_ids.append(credit_line)
@@ -154,6 +154,7 @@ 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')
class HrPayslipRun(models.Model):
@@ -42,6 +42,7 @@
<field name="arch" type="xml">
<xpath expr="//group[@name='duration_group']" position="after">
<group string="Accounting">
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
<field name="journal_id"/>
</group>
</xpath>