Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0.1.0.0][hr_holiday_multiple_approval] #232

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions hr_holiday_multiple_approval/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.. 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 Holiday Multiple Approval
============================

This module extends the functionality of HR Holiday
to support a Multiple Approval process.

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 Holiday Multiple Approval*
6. Install the module

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/open-synergy/opnsynid-hr/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
=======

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

* Andhitia Rama <andhitia.r@gmail.com>
* Michael Viriyananda <viriyananda.michael@gmail.com>

Maintainer
----------

.. image:: https://simetri-sinergi.id/logo.png
:alt: PT. Simetri Sinergi Indonesia
:target: https://simetri-sinergi.id.com

This module is maintained by the PT. Simetri Sinergi Indonesia.
11 changes: 11 additions & 0 deletions hr_holiday_multiple_approval/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright 2020 OpenSynergy Indonesia
# Copyright 2020 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import(
models,
)

from .hooks import (
set_double_validation_false,
)
25 changes: 25 additions & 0 deletions hr_holiday_multiple_approval/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Copyright 2020 OpenSynergy Indonesia
# Copyright 2020 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# pylint: disable=locally-disabled, manifest-required-author
{
"name": "HR Holiday Multiple Approval",
"version": "8.0.1.0.0",
"website": "https://simetri-sinergi.id",
"author": "PT. Simetri Sinergi Indonesia, OpenSynergy Indonesia",
"license": "AGPL-3",
"installable": True,
"auto_install": True,
"depends": [
"hr_holidays",
],
"data": [
"views/hr_holidays_view.xml",
"views/hr_holidays_status_view.xml",
],
"images": [
"static/description/banner.png",
],
"post_init_hook": "set_double_validation_false",
}
17 changes: 17 additions & 0 deletions hr_holiday_multiple_approval/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright 2020 OpenSynergy Indonesia
# Copyright 2020 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import SUPERUSER_ID


def set_double_validation_false(cr, registry):
obj_hr_holidays_status = registry["hr.holidays.status"]
criteria = [
("double_validation", "=", True)
]
status_ids = \
obj_hr_holidays_status.search(cr, SUPERUSER_ID, criteria)
if status_ids:
obj_hr_holidays_status.write(
cr, SUPERUSER_ID, status_ids, {"double_validation": False})
8 changes: 8 additions & 0 deletions hr_holiday_multiple_approval/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright 2020 OpenSynergy Indonesia
# Copyright 2020 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import(
hr_holidays,
tier_definition,
)
43 changes: 43 additions & 0 deletions hr_holiday_multiple_approval/models/hr_holidays.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
# Copyright 2020 OpenSynergy Indonesia
# Copyright 2020 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import api, models


class HrHolidays(models.Model):
_name = "hr.holidays"
_inherit = [
"hr.holidays",
"tier.validation",
]
_state_from = [
"draft",
"confirm",
]
_state_to = [
"validate",
]
_cancel_state = "refuse"

@api.multi
def validate_tier(self):
_super = super(HrHolidays, self)
_super.validate_tier()
for document in self:
if document.validated:
document.signal_workflow("validate")

@api.multi
def restart_validation(self):
_super = super(HrHolidays, self)
_super.restart_validation()
for document in self:
document.request_validation()

@api.multi
def holidays_confirm(self):
_super = super(HrHolidays, self)
_super.holidays_confirm()
for document in self:
document.request_validation()
15 changes: 15 additions & 0 deletions hr_holiday_multiple_approval/models/tier_definition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# Copyright 2020 OpenSynergy Indonesia
# Copyright 2020 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import api, models


class TierDefinition(models.Model):
_inherit = "tier.definition"

@api.model
def _get_tier_validation_model_names(self):
res = super(TierDefinition, self)._get_tier_validation_model_names()
res.append("hr.holidays")
return res
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions hr_holiday_multiple_approval/views/hr_holidays_status_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<!-- Copyright 2020 OpenSynergy Indonesia
Copyright 2020 PT. Simetri Sinergi Indonesia
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<openerp>
<data>
<record id="hr_holidays_status_view_form" model="ir.ui.view">
<field name="name">hr.holidays.status.multiple.approval.form</field>
<field name="model">hr.holidays.status</field>
<field name="inherit_id" ref="hr_holidays.edit_holiday_status_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='double_validation']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
</data>
</openerp>
89 changes: 89 additions & 0 deletions hr_holiday_multiple_approval/views/hr_holidays_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0"?>
<!-- Copyright 2020 OpenSynergy Indonesia
Copyright 2020 PT. Simetri Sinergi Indonesia
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<openerp>
<data>
<record id="hr_holidays_view_form" model="ir.ui.view">
<field name="name">hr.holidays.multiple.approval.form</field>
<field name="model">hr.holidays</field>
<field name="inherit_id" ref="hr_holidays.edit_holiday_new" />
<field name="arch" type="xml">
<xpath expr="//button[@name='confirm']" position="before">
<button name="request_validation"
string="Request Validation"
attrs="{'invisible': ['|','|',('need_validation', '!=', True),('rejected','=',True),('state','not in',['confirm'])]}"
type="object"/>
<button name="restart_validation"
string="Restart Validation"
attrs="{'invisible': ['|','|',('review_ids', '=', []),('rejected','=',False),('state','not in',['confirm'])]}"
type="object"/>
</xpath>
<xpath expr="//button[@name='validate']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='reset']" position="replace">
<button string="Reset to Draft" name="reset" type="workflow"
attrs="{'invisible': ['|', ('can_reset', '=', False), ('state', 'not in', ['refuse'])]}"/>
</xpath>
<xpath expr="//header" position="after">
<field name="need_validation" invisible="1"/>
<field name="validated" invisible="1"/>
<field name="rejected" invisible="1"/>
<div class="alert alert-warning"
attrs="{'invisible': ['|', '|', '|',
('validated', '=', True), ('state', 'not in', ['confirm']),
('rejected', '=', True), ('review_ids', '=', [])]}"
style="margin-bottom:0px;">
<p><i class="fa fa-info-circle"/>This Holiday needs to be
validated.
<button name="validate_tier"
string="Validate"
attrs="{'invisible': [('review_ids', '=', [])]}"
type="object"
class="oe_inline oe_button btn-success"
icon="terp-check"/>
<button name="reject_tier"
string="Reject"
type="object"
class="btn-icon btn-danger"
icon="terp-gtk-stop"/>
</p>
</div>
<div class="alert alert-success"
attrs="{'invisible': ['|', '|', ('validated', '!=', True), ('state', 'not in', ['confirm']), ('review_ids', '=', [])]}"
style="margin-bottom:0px;">
<p><i class="fa fa-thumbs-up"/> Operation has been <b>validated</b>!</p>
</div>
<div class="alert alert-danger"
attrs="{'invisible': ['|', '|', ('rejected', '!=', True), ('state', 'not in', ['confirm']), ('review_ids', '=', [])]}"
style="margin-bottom:0px;">
<p><i class="fa fa-thumbs-down"/> Operation has been <b>rejected</b>.</p>
</div>
</xpath>
<xpath expr="//field[@name='notes']" position="after">
<separator string="Reviews"/>
<group>
<field name="definition_id"/>
<field name="reviewer_partner_ids" widget="many2many_tags"/>
<field name="review_ids" readonly="1"/>
</group>
</xpath>
</field>
</record>

<record id="hr_holidays_view_search" model="ir.ui.view">
<field name="name">hr.holidays.multiple.approval.search</field>
<field name="model">hr.holidays</field>
<field name="inherit_id" ref="hr_holidays.view_hr_holidays_filter"/>
<field name="arch" type="xml">
<xpath expr="//filter[@name='my_department_leaves']" position="before">
<filter name="needs_review" string="Needs my Review"
domain="[('reviewer_ids','in',uid), ('state', 'not in', ['validate', 'refuse'])]"
help="My Holidays to review"/>
</xpath>
</field>
</record>

</data>
</openerp>