Skip to content

Commit

Permalink
[8.0.1.0.0] hr_payslip_timesheet_computation
Browse files Browse the repository at this point in the history
  • Loading branch information
andhit-r committed May 26, 2018
1 parent 45a27e2 commit 588b1bd
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 0 deletions.
39 changes: 39 additions & 0 deletions hr_payslip_timesheet_computation/README.rst
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

==============================================
Payslip Integration With Timesheet Computation
==============================================


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 *Payslip Integration With Timesheet Computation*
6. Install the module

Credits
=======

Contributors
------------

* Michael Viriyananda <viriyananda.michael@gmail.com>
* Andhitia Rama <andhitia.r@gmail.com>
* Nurazmi <azmimr67@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.
5 changes: 5 additions & 0 deletions hr_payslip_timesheet_computation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2018 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
19 changes: 19 additions & 0 deletions hr_payslip_timesheet_computation/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2018 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Payslip Integration With Timesheet Computation",
"version": "8.0.1.0.0",
"category": "Human Resource",
"website": "https://opensynergy-indonesia.com",
"author": "OpenSynergy Indonesia",
"license": "AGPL-3",
"installable": True,
"depends": [
"hr_payroll",
"hr_timesheet_computation",
],
"data": [
"views/hr_payslip_views.xml",
],
}
6 changes: 6 additions & 0 deletions hr_payslip_timesheet_computation/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2018 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import hr_payslip
from . import hr_salary_rule
36 changes: 36 additions & 0 deletions hr_payslip_timesheet_computation/models/hr_payslip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Copyright 2018 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models, fields, api


class HrPayslip(models.Model):
_inherit = "hr.payslip"

@api.multi
@api.depends(
"employee_id", "date_from", "date_to")
def _compute_computation_ids(self):
obj_sheet = self.env["hr_timesheet_sheet.sheet"]
for payslip in self:
computation_ids = []
criteria = [
("employee_id", "=", payslip.employee_id.id),
("date_from", ">=", payslip.date_from),
("date_to", "<=", payslip.date_to),
("state", "=", "done"),
]
timesheets = obj_sheet.search(criteria)
for timesheet in timesheets:
computation_ids += timesheet.computation_ids.ids
payslip.timesheet_computation_ids = [(6, 0, computation_ids)]

timesheet_computation_ids = fields.Many2many(
string="Timesheet Computations",
comodel_name="hr.timesheet_computation",
compute="_compute_computation_ids",
relation="rel_payslip_2_timesheet_computation",
column1="payslip_id",
column2="computation_id",
)
34 changes: 34 additions & 0 deletions hr_payslip_timesheet_computation/models/hr_salary_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright 2018 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models, api


class HrSalaryRule(models.Model):
_inherit = "hr.salary.rule"

@api.multi
def compute_rule(self, localdict):
self.ensure_one()

class BrowsableObject(object):

def __init__(self, dict):
self.dict = dict

def __getattr__(self, attr):
return attr in self.dict and self.dict.__getitem__(attr) or 0.0

payslip = localdict["payslip"]
if not isinstance(payslip, type(self.env["hr.payslip"])):
payslip = payslip.dict
payslip.refresh()
localdict["payslip"] = payslip
ts_computations = {}
for ts_computation in payslip.timesheet_computation_ids:
ts_computations[ts_computation.item_id.code] = ts_computation
obj_ts_computation = BrowsableObject(ts_computations)
localdict["ts_computations"] = obj_ts_computation

return super(HrSalaryRule, self).compute_rule(self.id, localdict)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions hr_payslip_timesheet_computation/views/hr_payslip_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="hr_payslip_view_form" model="ir.ui.view">
<field name="name">hr.payslip form</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="//field[@name='input_line_ids']" position="after">
<separator name="timesheet_computation" string="Timesheet Computation"/>
<field name="timesheet_computation_ids" colspan="4" nolabel="1">
<tree>
<field name="sheet_id"/>
<field name="item_id"/>
<field name="amount"/>
</tree>
</field>
</xpath>
</field>
</record>

</data>
</openerp>

0 comments on commit 588b1bd

Please sign in to comment.