-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding new module hr_payslip_compute_sheet
Revision
- Loading branch information
Showing
9 changed files
with
228 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,39 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
======================== | ||
HR Payslip Compute Sheet | ||
======================== | ||
|
||
This module adds a wizard to compute sheet. | ||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to: | ||
|
||
1. Clone the branch 8.0 of the repository https://github.com/open-synergy/opnsynid-hr | ||
2. Add the path to this repository in your configuration (addons-path) | ||
3. Update the module list | ||
4. Go to menu *Setting -> Modules -> Local Modules* | ||
5. Search For *HR Payslip Compute Sheet* | ||
6. Install the module | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Michael Viriyananda <viriyananda.michael@gmail.com> | ||
* Andhitia Rama <andhitia.r@gmail.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://opensynergy-indonesia.com/logo.png | ||
:alt: OpenSynergy Indonesia | ||
:target: https://opensynergy-indonesia.com | ||
|
||
This module is maintained by the OpenSynergy Indonesia. |
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,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import wizards |
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 -*- | ||
# Copyright 2016 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "HR Payslip Compute Sheet", | ||
"version": "8.0.1.0.0", | ||
"summary": "Adds wizard to compute sheet", | ||
"category": "Human Resources", | ||
"website": "https://opensynergy-indonesia.com", | ||
"author": "OpenSynergy Indonesia", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"depends": ["hr_payroll"], | ||
"data": [ | ||
"wizards/hr_compute_sheet_views.xml", | ||
"views/hr_payslip_views.xml", | ||
"data/ir_values_data.xml" | ||
], | ||
} |
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,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
|
||
<record id="hr_compute_sheet_value" model="ir.values"> | ||
<field name="model_id" ref="hr_payroll.model_hr_payslip" /> | ||
<field name="name">Compute Sheet</field> | ||
<field name="key2">client_action_multi</field> | ||
<field name="value" eval="'ir.actions.act_window,' + str(ref('hr_compute_sheet_action'))" /> | ||
<field name="key">action</field> | ||
<field name="model">hr.payslip</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
Loading
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,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
|
||
<record id="hr_payslip_view_tree" model="ir.ui.view"> | ||
<field name="name">Inherit HR Payslip Tree</field> | ||
<field name="model">hr.payslip</field> | ||
<field name="inherit_id" ref="hr_payroll.view_hr_payslip_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//button[@name='compute_sheet']" position="after"> | ||
<button | ||
name="%(hr_compute_sheet_action)d" | ||
type="action" | ||
string="Compute Sheet" | ||
states="draft" | ||
class="oe_highlight" | ||
/> | ||
</xpath> | ||
<xpath expr="//button[@name='compute_sheet']" position="attributes"> | ||
<attribute name="invisible">True</attribute> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> | ||
|
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,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import hr_compute_sheet |
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,85 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp import models, fields, api, _ | ||
from openerp.exceptions import Warning as UserError | ||
|
||
|
||
class HrComputeSheet(models.TransientModel): | ||
_name = 'hr.compute_sheet' | ||
_description = 'HR Compute Sheet' | ||
|
||
reload_input = fields.Boolean( | ||
string="Reload Input", | ||
default=False | ||
) | ||
|
||
reload_workdays = fields.Boolean( | ||
string="Reload Workdays", | ||
default=False | ||
) | ||
|
||
def get_contract_ids(self, payslip): | ||
contract_ids = payslip.get_contract( | ||
employee=payslip.employee_id, | ||
date_from=payslip.date_from, | ||
date_to=payslip.date_to) | ||
return contract_ids | ||
|
||
def _reload_input(self, payslip): | ||
contract_ids = self.get_contract_ids(payslip) | ||
input_line_ids = payslip.get_inputs( | ||
contract_ids=contract_ids, | ||
date_from=payslip.date_from, | ||
date_to=payslip.date_to) | ||
if input_line_ids: | ||
for input_line in payslip.input_line_ids: | ||
reset = { | ||
'input_line_ids': [(2, input_line.id)] | ||
} | ||
payslip.write(reset) | ||
vals = { | ||
'input_line_ids': [(0, 0, input_line_ids[0])] | ||
} | ||
payslip.write(vals) | ||
|
||
def _reload_workdays(self, payslip): | ||
contract_ids = self.get_contract_ids(payslip) | ||
worked_days_line_ids = payslip.get_worked_day_lines( | ||
contract_ids=contract_ids, | ||
date_from=payslip.date_from, | ||
date_to=payslip.date_to) | ||
if worked_days_line_ids: | ||
for worked_days in payslip.worked_days_line_ids: | ||
reset = { | ||
'worked_days_line_ids': [(2, worked_days.id)] | ||
} | ||
payslip.write(reset) | ||
vals = { | ||
'worked_days_line_ids': [( | ||
0, 0, worked_days_line_ids[0])] | ||
} | ||
payslip.write(vals) | ||
|
||
@api.multi | ||
def button_compute_sheet(self): | ||
self.ensure_one() | ||
obj_hr_payslip = self.env['hr.payslip'] | ||
context = self._context | ||
record_ids = context['active_ids'] | ||
|
||
for payslip in obj_hr_payslip.browse(record_ids): | ||
if payslip.state == 'draft': | ||
if self.reload_input: | ||
self._reload_input(payslip) | ||
if self.reload_workdays: | ||
self._reload_workdays(payslip) | ||
else: | ||
raise UserError( | ||
_('Payslip No. %s ' | ||
'cannot be computed ' | ||
'because state is done.') % (payslip.number,)) | ||
payslip.compute_sheet() | ||
|
||
return {'type': 'ir.actions.act_window_close'} |
33 changes: 33 additions & 0 deletions
33
hr_payslip_compute_sheet/wizards/hr_compute_sheet_views.xml
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,33 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
|
||
<record id="hr_compute_sheet_view_form" model="ir.ui.view"> | ||
<field name="name">HR Compute Sheet Form</field> | ||
<field name="model">hr.compute_sheet</field> | ||
<field name="arch" type="xml"> | ||
<form string="Compute Sheet"> | ||
<group colspan="2" col="2"> | ||
<field name="reload_input"/> | ||
<field name="reload_workdays"/> | ||
</group> | ||
<footer> | ||
<button string="Compute" name="button_compute_sheet" type="object" class="oe_highlight"/> | ||
or | ||
<button string="Cancel" class="oe_link" special="cancel"/> | ||
</footer> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="hr_compute_sheet_action" model="ir.actions.act_window"> | ||
<field name="name">Compute Sheet</field> | ||
<field name="res_model">hr.compute_sheet</field> | ||
<field name="view_type">form</field> | ||
<field name="view_mode">tree,form</field> | ||
<field name="view_id" ref="hr_compute_sheet_view_form"/> | ||
<field name="target">new</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |