From 0fa32b27c846793f0bc264349d8ce87f5e246fe5 Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Wed, 23 Jan 2019 18:36:40 +0100 Subject: [PATCH 1/2] Revert "[IMP] hr_payroll_account: Remove unused field" This reverts commit 89b12e9857c79069af36418bd1f5eda697159e37. --- addons/hr_payroll_account/models/hr_payroll_account.py | 1 + addons/hr_payroll_account/views/hr_payroll_account_views.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/addons/hr_payroll_account/models/hr_payroll_account.py b/addons/hr_payroll_account/models/hr_payroll_account.py index c2b80fc744f..a36d5c3655f 100644 --- a/addons/hr_payroll_account/models/hr_payroll_account.py +++ b/addons/hr_payroll_account/models/hr_payroll_account.py @@ -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 @@ + From 691712eb43d597fd2c9452bb877044d22238b9ae Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Wed, 23 Jan 2019 18:39:29 +0100 Subject: [PATCH 2/2] [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 --- addons/hr_payroll_account/models/hr_payroll_account.py | 4 ++-- 1 file changed, 2 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 a36d5c3655f..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)