From eb8b281382089c5fa64a74579f831ecd69ca91d9 Mon Sep 17 00:00:00 2001 From: dufresnedavid Date: Sun, 15 Mar 2015 09:57:56 -0400 Subject: [PATCH] [ADD] Module hr_employee_exemption --- hr_employee_exemption/README.rst | 48 ++++++++ hr_employee_exemption/__init__.py | 26 +++++ hr_employee_exemption/__openerp__.py | 44 +++++++ hr_employee_exemption/hr_employee.py | 47 ++++++++ .../hr_employee_exemption.py | 43 +++++++ .../hr_income_tax_exemption.py | 35 ++++++ hr_employee_exemption/i18n/fr.po | 77 ++++++++++++ .../i18n/hr_employee_exemption.pot | 76 ++++++++++++ .../security/ir.model.access.csv | 3 + hr_employee_exemption/static/src/img/icon.png | Bin 0 -> 5938 bytes hr_employee_exemption/tests/__init__.py | 28 +++++ .../tests/test_hr_employee_exemption.py | 110 ++++++++++++++++++ .../view/hr_employee_view.xml | 23 ++++ .../view/hr_income_tax_exemption_view.xml | 31 +++++ 14 files changed, 591 insertions(+) create mode 100644 hr_employee_exemption/README.rst create mode 100644 hr_employee_exemption/__init__.py create mode 100644 hr_employee_exemption/__openerp__.py create mode 100644 hr_employee_exemption/hr_employee.py create mode 100644 hr_employee_exemption/hr_employee_exemption.py create mode 100644 hr_employee_exemption/hr_income_tax_exemption.py create mode 100644 hr_employee_exemption/i18n/fr.po create mode 100644 hr_employee_exemption/i18n/hr_employee_exemption.pot create mode 100644 hr_employee_exemption/security/ir.model.access.csv create mode 100644 hr_employee_exemption/static/src/img/icon.png create mode 100644 hr_employee_exemption/tests/__init__.py create mode 100644 hr_employee_exemption/tests/test_hr_employee_exemption.py create mode 100644 hr_employee_exemption/view/hr_employee_view.xml create mode 100644 hr_employee_exemption/view/hr_income_tax_exemption_view.xml diff --git a/hr_employee_exemption/README.rst b/hr_employee_exemption/README.rst new file mode 100644 index 00000000000..74ffafb161a --- /dev/null +++ b/hr_employee_exemption/README.rst @@ -0,0 +1,48 @@ +Employee Exemption +================== + +This module implements employee exemption. +This allows in salary rules to know whether the employee is exempted from a source deduction. + + +Usage +===== + +Go to: Human Resources -> Configuration -> Payroll -> Income Tax Exemptions +Create exemption types +exemple: + - name: 'Exemption from federal tax' + - code: 'FED' + +Go to: Human Resources -> Human Resources -> Employees +Select an employee +In the Tax Exemptions tab, add exemptions + +In your salary rules, you may access check if an employee is exempted from a source deduction: +if employee.exempted_from('FED', payslip.date_from): + result = ... +else: + result = ... + + +Credits +======= + +Contributors +------------ +* David Dufresne +* Maxime Chambreuil +* Pierre Lamarche + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://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 http://odoo-community.org. diff --git a/hr_employee_exemption/__init__.py b/hr_employee_exemption/__init__.py new file mode 100644 index 00000000000..71b4e2d2ed8 --- /dev/null +++ b/hr_employee_exemption/__init__.py @@ -0,0 +1,26 @@ +# -*- coding:utf-8 -*- +############################################################################## +# +# Copyright (C) 2015 Savoir-faire Linux. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import ( + hr_employee, + hr_employee_exemption, + hr_income_tax_exemption, +) diff --git a/hr_employee_exemption/__openerp__.py b/hr_employee_exemption/__openerp__.py new file mode 100644 index 00000000000..bbc52028f67 --- /dev/null +++ b/hr_employee_exemption/__openerp__.py @@ -0,0 +1,44 @@ +# -*- coding:utf-8 -*- +############################################################################## +# +# Copyright (C) 2015 Savoir-faire Linux. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': 'Employee Exemption', + 'version': '1.0', + 'license': 'AGPL-3', + 'category': 'Generic Modules/Human Resources', + 'author': "Savoir-faire Linux, Odoo Community Association (OCA)", + 'website': 'https://www.savoirfairelinux.com', + 'description': """ +Employee Exemption +================== +Add employee benefits in order to compute payslips. + """, + 'depends': [ + 'hr_payroll', + ], + 'data': [ + 'security/ir.model.access.csv', + 'view/hr_employee_view.xml', + 'view/hr_income_tax_exemption_view.xml', + ], + 'test': [], + 'demo': [], + 'installable': True, +} diff --git a/hr_employee_exemption/hr_employee.py b/hr_employee_exemption/hr_employee.py new file mode 100644 index 00000000000..d96f276882e --- /dev/null +++ b/hr_employee_exemption/hr_employee.py @@ -0,0 +1,47 @@ +# -*- coding:utf-8 -*- +############################################################################## +# +# Copyright (C) 2015 Savoir-faire Linux. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm, fields + + +class hr_employee_exemption(orm.Model): + _inherit = 'hr.employee' + + _columns = { + 'exemption_ids': fields.one2many( + 'hr.employee.exemption', + 'employee_id', + 'Income Tax Exemptions', + ), + } + + def exempted_from(self, cr, uid, ids, code, date, context=None): + """ + The method to call from a salary rule to check whether an employee + is exempted from a source deduction + """ + employee = self.browse(cr, uid, ids[0], context=context) + for exemption in employee.exemption_ids: + if exemption.exemption_id.code == code and \ + exemption.date_from <= date and ( + not exemption.date_to or date <= exemption.date_to): + return True + return False diff --git a/hr_employee_exemption/hr_employee_exemption.py b/hr_employee_exemption/hr_employee_exemption.py new file mode 100644 index 00000000000..3e5c1624c2e --- /dev/null +++ b/hr_employee_exemption/hr_employee_exemption.py @@ -0,0 +1,43 @@ +# -*- coding:utf-8 -*- +############################################################################## +# +# Copyright (C) 2015 Savoir-faire Linux. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm, fields + + +class hr_employee_exemption(orm.Model): + _name = 'hr.employee.exemption' + _description = 'Employee Income Tax Exemption' + + _columns = { + 'employee_id': fields.many2one( + 'hr.employee', + 'Employee', + required=True, + ondelete='cascade', + ), + 'exemption_id': fields.many2one( + 'hr.income.tax.exemption', + 'Exemption', + required=True, + ), + 'date_from': fields.date('Date From', required=True), + 'date_to': fields.date('Date To'), + } diff --git a/hr_employee_exemption/hr_income_tax_exemption.py b/hr_employee_exemption/hr_income_tax_exemption.py new file mode 100644 index 00000000000..bb1b6388b9f --- /dev/null +++ b/hr_employee_exemption/hr_income_tax_exemption.py @@ -0,0 +1,35 @@ +# -*- coding:utf-8 -*- +############################################################################## +# +# Copyright (C) 2015 Savoir-faire Linux. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import fields, orm + + +class hr_income_tax_exemption(orm.Model): + _name = 'hr.income.tax.exemption' + _description = 'Income Tax Exemption' + _columns = { + 'name': fields.char('Name', required=True), + 'code': fields.char( + 'Code', required=True, help="" + "The code that can be used in the salary rules to identify " + "the exemption" + ), + } diff --git a/hr_employee_exemption/i18n/fr.po b/hr_employee_exemption/i18n/fr.po new file mode 100644 index 00000000000..478c152413a --- /dev/null +++ b/hr_employee_exemption/i18n/fr.po @@ -0,0 +1,77 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * hr_employee_exemption +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-03-14 18:29+0000\n" +"PO-Revision-Date: 2015-03-14 14:34-0500\n" +"Last-Translator: David Dufresne \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 1.5.4\n" + +#. module: hr_employee_exemption +#: model:ir.model,name:hr_employee_exemption.model_hr_employee_exemption +msgid "hr.employee.exemption" +msgstr "hr.employee.exemption" + +#. module: hr_employee_exemption +#: field:hr.income.tax.exemption,code:0 +msgid "Code" +msgstr "Code" + +#. module: hr_employee_exemption +#: field:hr.employee.exemption,exemption_id:0 +msgid "Exemption" +msgstr "Exonération" + +#. module: hr_employee_exemption +#: field:hr.income.tax.exemption,name:0 +msgid "Name" +msgstr "Nom" + +#. module: hr_employee_exemption +#: field:hr.employee,exemption_ids:0 view:hr.income.tax.exemption:0 +#: model:ir.actions.act_window,name:hr_employee_exemption.action_hr_income_tax_exemption_list +#: model:ir.ui.menu,name:hr_employee_exemption.menu_action_hr_income_tax_exemption_list +msgid "Income Tax Exemptions" +msgstr "Exonérations d'impôt" + +#. module: hr_employee_exemption +#: view:hr.employee:0 +msgid "Tax Exemptions" +msgstr "Exonérations d'impôt" + +#. module: hr_employee_exemption +#: help:hr.income.tax.exemption,code:0 +msgid "The code that can be used in the salary rules to identify the exemption" +msgstr "" +"Le code pouvant être utilisé dans les règles de salaire pour identifier " +"l'exonération." + +#. module: hr_employee_exemption +#: field:hr.employee.exemption,date_to:0 +msgid "Date To" +msgstr "Date de début" + +#. module: hr_employee_exemption +#: model:ir.model,name:hr_employee_exemption.model_hr_income_tax_exemption +msgid "Income Tax Exemption" +msgstr "Exonération d'impôt" + +#. module: hr_employee_exemption +#: field:hr.employee.exemption,date_from:0 +msgid "Date From" +msgstr "Date de fin" + +#. module: hr_employee_exemption +#: field:hr.employee.exemption,employee_id:0 +#: model:ir.model,name:hr_employee_exemption.model_hr_employee +msgid "Employee" +msgstr "Employé" diff --git a/hr_employee_exemption/i18n/hr_employee_exemption.pot b/hr_employee_exemption/i18n/hr_employee_exemption.pot new file mode 100644 index 00000000000..a81502ec8db --- /dev/null +++ b/hr_employee_exemption/i18n/hr_employee_exemption.pot @@ -0,0 +1,76 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * hr_employee_exemption +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-03-14 18:29+0000\n" +"PO-Revision-Date: 2015-03-14 18:29+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: hr_employee_exemption +#: model:ir.model,name:hr_employee_exemption.model_hr_employee_exemption +msgid "hr.employee.exemption" +msgstr "" + +#. module: hr_employee_exemption +#: field:hr.income.tax.exemption,code:0 +msgid "Code" +msgstr "" + +#. module: hr_employee_exemption +#: field:hr.employee.exemption,exemption_id:0 +msgid "Exemption" +msgstr "" + +#. module: hr_employee_exemption +#: field:hr.income.tax.exemption,name:0 +msgid "Name" +msgstr "" + +#. module: hr_employee_exemption +#: field:hr.employee,exemption_ids:0 +#: view:hr.income.tax.exemption:0 +#: model:ir.actions.act_window,name:hr_employee_exemption.action_hr_income_tax_exemption_list +#: model:ir.ui.menu,name:hr_employee_exemption.menu_action_hr_income_tax_exemption_list +msgid "Income Tax Exemptions" +msgstr "" + +#. module: hr_employee_exemption +#: view:hr.employee:0 +msgid "Tax Exemptions" +msgstr "" + +#. module: hr_employee_exemption +#: help:hr.income.tax.exemption,code:0 +msgid "The code that can be used in the salary rules to identify the exemption" +msgstr "" + +#. module: hr_employee_exemption +#: field:hr.employee.exemption,date_to:0 +msgid "Date To" +msgstr "" + +#. module: hr_employee_exemption +#: model:ir.model,name:hr_employee_exemption.model_hr_income_tax_exemption +msgid "Income Tax Exemption" +msgstr "" + +#. module: hr_employee_exemption +#: field:hr.employee.exemption,date_from:0 +msgid "Date From" +msgstr "" + +#. module: hr_employee_exemption +#: field:hr.employee.exemption,employee_id:0 +#: model:ir.model,name:hr_employee_exemption.model_hr_employee +msgid "Employee" +msgstr "" + diff --git a/hr_employee_exemption/security/ir.model.access.csv b/hr_employee_exemption/security/ir.model.access.csv new file mode 100644 index 00000000000..f012a0b7702 --- /dev/null +++ b/hr_employee_exemption/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_hr_income_tax_exemption,access_hr_income_tax_exemption,model_hr_income_tax_exemption,base.group_hr_manager,1,1,1,1 +access_hr_employee_exemption,access_hr_employee_exemption,model_hr_employee_exemption,base.group_hr_manager,1,1,1,1 diff --git a/hr_employee_exemption/static/src/img/icon.png b/hr_employee_exemption/static/src/img/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..297dc71c85c5fdd8deafabfbb46093e04adc32d1 GIT binary patch literal 5938 zcmZ{oWmFXI^Y&S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iInYFH`6Hf7)O~;ahL_4ubvp9`%UGp z$4M(6d~&)2-lA0-nLOpnwZuxjB`(iIufhdS;V%yiTBR5ca;J7Iwk%4mY5;+dFI7V; zz7^=|Q!NMo{@GM4@(t6Bw4yNg>M1as7 z(YKyLW4AaK(X=h#HMD}7BWG+}9EgNBfcL11b-Jw{g-ZnBAypD%V{C=a_RP9+%&mXv zYA!=`cuYK?S`G+ECwenaSJ^Yf?T3E1pL`42z?_cH$B1^Uy`R%FUR#geTc;oQU4v5O zDWGtLejeaw9f<(a^=oi+1*;)Np4onst25!+{sHy+FbRRd zPn{b1<`{#;i4{Pd-v>#1N^|3=j~2yNm1MJzAOMP%14VIuUuBixf~dO?jso!wj36qN#&u}7i( z(&mmB*QfBxJUKMh_Wbz~@Oh@10!Aik%d(Qjwj{icpZ#2S^1pDcuy{pM!1qsjWuJci zcS>gZplI~L&iaGBn5~cfKOpe&@Q8B$d%XO5yaHmp{9-&j>^yw`@*g!m+W*Jk?rG=j z5cK~yWRfPA{WFmNH$m6a;X{D6k3B*_KmeDshpVrxwU<4Yr;lU)xdg?(CInSQ4TVNI HtLXm&e3x`` literal 0 HcmV?d00001 diff --git a/hr_employee_exemption/tests/__init__.py b/hr_employee_exemption/tests/__init__.py new file mode 100644 index 00000000000..7c09cee4391 --- /dev/null +++ b/hr_employee_exemption/tests/__init__.py @@ -0,0 +1,28 @@ +# -*- coding:utf-8 -*- +############################################################################## +# +# Copyright (C) 2015 Savoir-faire Linux. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import ( + test_hr_employee_exemption, +) + +checks = [ + test_hr_employee_exemption, +] diff --git a/hr_employee_exemption/tests/test_hr_employee_exemption.py b/hr_employee_exemption/tests/test_hr_employee_exemption.py new file mode 100644 index 00000000000..1af074a350f --- /dev/null +++ b/hr_employee_exemption/tests/test_hr_employee_exemption.py @@ -0,0 +1,110 @@ +# -*- coding:utf-8 -*- +############################################################################## +# +# Copyright (C) 2015 Savoir-faire Linux. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.tests import common + + +class test_hr_employee_exemption(common.TransactionCase): + def setUp(self): + super(test_hr_employee_exemption, self).setUp() + self.employee_model = self.registry('hr.employee') + self.exemption_model = self.registry('hr.income.tax.exemption') + self.user_model = self.registry("res.users") + + self.context = self.user_model.context_get(self.cr, self.uid) + + cr, uid, context = self.cr, self.uid, self.context + + self.exemption_1 = self.exemption_model.create(cr, uid, { + 'name': 'Test', + 'code': 'TEST_1', + }, context=context) + + self.exemption_2 = self.exemption_model.create(cr, uid, { + 'name': 'Test', + 'code': 'TEST_2', + }, context=context) + + self.employee_id = self.employee_model.create( + cr, uid, { + 'name': 'Employee 1' + }, context=context) + + def add_exemption(self, exemption): + cr, uid, context = self.cr, self.uid, self.context + employee = self.employee_model.browse( + cr, uid, self.employee_id, context=context) + + employee.write({'exemption_ids': [(0, 0, { + 'exemption_id': exemption, + 'date_from': '2015-01-01', + 'date_to': '2015-12-31', + })]}) + + def test_exempted_from_no_exemption(self): + cr, uid, context = self.cr, self.uid, self.context + employee = self.employee_model.browse( + cr, uid, self.employee_id, context=context) + + self.assertEqual(employee.exempted_from('TEST_1', '2015-01-01'), False) + + def test_exempted_from_one_exemption(self): + cr, uid, context = self.cr, self.uid, self.context + self.add_exemption(self.exemption_1) + + employee = self.employee_model.browse( + cr, uid, self.employee_id, context=context) + + self.assertEqual(employee.exempted_from('TEST_1', '2015-01-01'), True) + self.assertEqual(employee.exempted_from('TEST_2', '2015-01-01'), False) + + self.assertEqual(employee.exempted_from('TEST_1', '2014-12-31'), False) + self.assertEqual(employee.exempted_from('TEST_1', '2015-12-31'), True) + self.assertEqual(employee.exempted_from('TEST_1', '2016-01-01'), False) + + def test_exempted_from_two_exemption(self): + cr, uid, context = self.cr, self.uid, self.context + self.add_exemption(self.exemption_1) + self.add_exemption(self.exemption_2) + + employee = self.employee_model.browse( + cr, uid, self.employee_id, context=context) + + self.assertEqual(employee.exempted_from('TEST_1', '2015-01-01'), True) + self.assertEqual(employee.exempted_from('TEST_2', '2015-01-01'), True) + + def test_exempted_from_no_date_to(self): + cr, uid, context = self.cr, self.uid, self.context + employee = self.employee_model.browse( + cr, uid, self.employee_id, context=context) + + employee.write({'exemption_ids': [(0, 0, { + 'exemption_id': self.exemption_1, + 'date_from': '2015-01-01', + })]}) + + self.assertEqual(employee.exempted_from('TEST_1', '2014-12-31'), False) + + self.assertEqual(employee.exempted_from('TEST_1', '2015-01-01'), True) + self.assertEqual(employee.exempted_from('TEST_2', '2015-01-01'), False) + + self.assertEqual(employee.exempted_from('TEST_1', '2016-01-01'), True) + self.assertEqual(employee.exempted_from('TEST_2', '2016-01-01'), False) diff --git a/hr_employee_exemption/view/hr_employee_view.xml b/hr_employee_exemption/view/hr_employee_view.xml new file mode 100644 index 00000000000..72335ac7ebe --- /dev/null +++ b/hr_employee_exemption/view/hr_employee_view.xml @@ -0,0 +1,23 @@ + + + + + hr.employee.form + hr.employee + + + + + + + + + + + + + + + + + diff --git a/hr_employee_exemption/view/hr_income_tax_exemption_view.xml b/hr_employee_exemption/view/hr_income_tax_exemption_view.xml new file mode 100644 index 00000000000..746552ad512 --- /dev/null +++ b/hr_employee_exemption/view/hr_income_tax_exemption_view.xml @@ -0,0 +1,31 @@ + + + + + + hr.income.tax.exemption.form + hr.income.tax.exemption + + + + + + + + + + Income Tax Exemptions + hr.income.tax.exemption + form + + + + + + +