diff options
| author | Robot Odoo <xmo+roboto@odoo.com> | 2019-01-24 14:29:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-24 14:29:16 +0100 |
| commit | af1728fddf61c0bc35c4fd7a9c139ab7b1feefd0 (patch) | |
| tree | 59585e33aa1f3a533f08952f60be8edb0e9740b6 | |
| parent | 4704128dc4bb10f6d6492a459f7ae140be212d7c (diff) | |
| parent | 691712eb43d597fd2c9452bb877044d22238b9ae (diff) | |
[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
| -rw-r--r-- | addons/hr_payroll_account/models/hr_payroll_account.py | 5 | ||||
| -rw-r--r-- | addons/hr_payroll_account/views/hr_payroll_account_views.xml | 1 |
2 files changed, 4 insertions, 2 deletions
diff --git a/addons/hr_payroll_account/models/hr_payroll_account.py b/addons/hr_payroll_account/models/hr_payroll_account.py index c2b80fc744f..82117e38cdd 100644 --- a/addons/hr_payroll_account/models/hr_payroll_account.py +++ b/addons/hr_payroll_account/models/hr_payroll_account.py @@ -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): diff --git a/addons/hr_payroll_account/views/hr_payroll_account_views.xml b/addons/hr_payroll_account/views/hr_payroll_account_views.xml index 8c392536db8..fa4d9cd6258 100644 --- a/addons/hr_payroll_account/views/hr_payroll_account_views.xml +++ b/addons/hr_payroll_account/views/hr_payroll_account_views.xml @@ -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> |
