Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
.. image:: https://img.shields.io/badge/license-LGPLv3-blue.svg | ||
:target: https://www.gnu.org/licenses/lgpl.html | ||
:alt: License: LGPL-3 | ||
|
||
======================================= | ||
HR Payroll Account with Operating Units | ||
======================================= | ||
|
||
This module introduces the following features: | ||
|
||
* Adds Operating Unit (OU) to the account moves and its lines created by the | ||
payslip, based on the Operating Unit (OU) defined in the Employee's Contract. | ||
|
||
Usage | ||
===== | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/213/9.0 | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/operating-unit/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Eficent Business and IT Consulting Services S.L. <contact@eficent.com> | ||
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Eficent Business and IT Consulting Services S.L. - | ||
# Jordi Ballester Alomar | ||
# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
from . import models | ||
from . import tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Eficent Business and IT Consulting Services S.L. - | ||
# Jordi Ballester Alomar | ||
# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
||
{ | ||
"name": "HR Payroll Account Operating Unit", | ||
"version": "9.0.1.0.0", | ||
"license": 'LGPL-3', | ||
"author": "Eficent Business and IT Consulting Services S.L., " | ||
"Serpent Consulting Services Pvt. Ltd.," | ||
"Odoo Community Association (OCA)", | ||
"category": "Generic Modules/Human Resources", | ||
"website": "http://www.eficent.com", | ||
"depends": ["hr_payroll_account", "hr_contract_operating_unit", | ||
"account_operating_unit"], | ||
'installable': True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Eficent Business and IT Consulting Services S.L. - | ||
# Jordi Ballester Alomar | ||
# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
from . import hr_payslip | ||
from . import account_move |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Eficent Business and IT Consulting Services S.L. - | ||
# Jordi Ballester Alomar | ||
# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
from openerp import api, models | ||
|
||
|
||
class AccountMove(models.Model): | ||
|
||
_inherit = 'account.move' | ||
|
||
@api.model | ||
def create(self, vals): | ||
if 'force_operating_unit' in self._context: | ||
for line in vals['line_ids']: | ||
line[2].update({'operating_unit_id': | ||
self._context['force_operating_unit']}) | ||
return super(AccountMove, self).create(vals) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Eficent Business and IT Consulting Services S.L. - | ||
# Jordi Ballester Alomar | ||
# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
from openerp.tools.translate import _ | ||
from openerp import models, api | ||
from openerp.exceptions import Warning as UserError | ||
|
||
|
||
class HrPayslip(models.Model): | ||
|
||
_inherit = 'hr.payslip' | ||
|
||
@api.multi | ||
def write(self, vals): | ||
res = super(HrPayslip, self).write(vals) | ||
if 'move_id' in vals and vals['move_id']: | ||
for slip in self: | ||
if slip.contract_id and slip.contract_id.operating_unit_id: | ||
slip.move_id.write({'operating_unit_id': | ||
slip.contract_id.operating_unit_id.id}) | ||
return res | ||
|
||
@api.cr_uid_ids_context | ||
def process_sheet(self, cr, uid, ids, context=None): | ||
OU = None | ||
payslip = self.browse(cr, uid, ids, context=context) | ||
for slip in payslip: | ||
# Check that all slips are related to contracts | ||
# that belong to the same OU. | ||
if OU: | ||
if slip.contract_id.operating_unit_id.id != OU: | ||
raise UserError(_('Configuration error!\nThe Contracts must\ | ||
refer the same Operating Unit.')) | ||
OU = slip.contract_id.operating_unit_id.id | ||
# Add to context the OU of the employee contract | ||
new_context = context.copy() | ||
new_context.update(force_operating_unit=OU) | ||
return super(HrPayslip, self).process_sheet(cr, uid, payslip.ids, | ||
new_context) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Eficent Business and IT Consulting Services S.L. | ||
# - Jordi Ballester Alomar | ||
# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
from . import test_payroll_account_operating_unit |
54 changes: 54 additions & 0 deletions
54
hr_payroll_account_operating_unit/tests/test_payroll_account_operating_unit.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Eficent Business and IT Consulting Services S.L. | ||
# - Jordi Ballester Alomar | ||
# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
from openerp.addons.hr_contract_operating_unit.tests\ | ||
import test_hr_contract_operating_unit | ||
|
||
|
||
class TestPayrollAccountOperatingUnit(test_hr_contract_operating_unit. | ||
TestHrContractOperatingUnit): | ||
|
||
def setUp(self): | ||
super(TestPayrollAccountOperatingUnit, self).setUp() | ||
self.hr_payslip_model = self.env['hr.payslip'] | ||
self.acc_move_model = self.env['account.move'] | ||
self.acc_journal_model = self.env['account.journal'] | ||
|
||
self.hr_payroll_struct = self.env.ref('hr_payroll.structure_base') | ||
# Add Payroll Salary Structure to Contract | ||
contracts = self.hr_contract1 + self.hr_contract2 | ||
contracts.write({'struct_id': self.hr_payroll_struct.id}) | ||
# Salary Journal | ||
self.journal = self.acc_journal_model.search([('type', '=', 'bank'), | ||
('name', '=', 'Bank')]) | ||
# Create Payslip 1 | ||
self.payslip1 = self._create_payslip(self.hr_contract1.id) | ||
# Create Payslip 2 | ||
self.payslip2 = self._create_payslip(self.hr_contract2.id) | ||
|
||
def _create_payslip(self, contract): | ||
"""Create a Pay-slip.""" | ||
payslip = self.hr_payslip_model.create({ | ||
'employee_id': self.emp.id, | ||
'contract_id': contract, | ||
'struct_id': self.hr_payroll_struct.id, | ||
'journal_id': self.journal.id | ||
}) | ||
payslip.hr_verify_sheet() | ||
payslip.process_sheet() | ||
return payslip | ||
|
||
def test_hr_payroll_account_ou(self): | ||
"""Test Payroll Account Operating Unit""" | ||
# Operating Unit (OU) of contract in Payslip should | ||
# match with OU of Accounting Entries of that Payslip | ||
self.assertEqual(self.payslip1.move_id.operating_unit_id, | ||
self.payslip1.contract_id.operating_unit_id, | ||
'Operating Unit (OU) of contract in Payslip should ' | ||
'match with Accounting Entries OU') | ||
self.assertEqual(self.payslip2.move_id.operating_unit_id, | ||
self.payslip2.contract_id.operating_unit_id, | ||
'Operating Unit (OU) of contract in Payslip should ' | ||
'match with Accounting Entries OU') |