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

[12.0.1.0.0] hr_job_family_modelling #175

Merged
merged 1 commit into from
May 10, 2019
Merged
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_job_family_modelling/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

====================
Job Family Modelling
====================



Installation
============

To install this module, you need to:

1. Clone the branch 12.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 *Job Family Modelling*
6. Install the module

Configuration
=============

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://opensynergy-indonesia.com/logo.png
:alt: OpenSynergy Indonesia
:target: https://opensynergy-indonesia.org

This module is maintained by the OpenSynergy Indonesia.
5 changes: 5 additions & 0 deletions hr_job_family_modelling/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2019 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
29 changes: 29 additions & 0 deletions hr_job_family_modelling/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2019 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# pylint: disable=locally-disabled, manifest-required-author
{
"name": "Job Family Modelling",
"summary": "Grading system that divides jobs into coherent groups "
"based on shared characteristics",
"version": "12.0.1.0.0",
"category": "Human Resources",
"website": "https://opensynergy-indonesia.com/",
"author": "OpenSynergy Indonesia",
"license": "AGPL-3",
"installable": True,
"depends": [
"hr",
],
"data": [
"security/ir.model.access.csv",
"menu.xml",
"views/hr_job_grade_category_views.xml",
"views/hr_job_grade_views.xml",
"views/hr_job_family_grade_views.xml",
"views/hr_job_family_views.xml",
"views/hr_job_family_level_views.xml",
"views/hr_job_views.xml",
"views/hr_employee_views.xml",
],
}
10 changes: 10 additions & 0 deletions hr_job_family_modelling/menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016-2019 OpenSynergy Indonesia
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->

<odoo>
<menuitem id="job_family_modelling_configuration_menu"
parent="hr.menu_human_resources_configuration"
name="Job Family Modelling"
sequence="5"/>
</odoo>
13 changes: 13 additions & 0 deletions hr_job_family_modelling/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# Copyright 2018-2019 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import (
hr_job_grade_category,
hr_job_grade,
hr_job_family_grade,
hr_job_family,
hr_job_family_level,
hr_employee,
hr_job,
)
32 changes: 32 additions & 0 deletions hr_job_family_modelling/models/hr_employee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Copyright 2018-2019 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models, fields, api


class HrEmployee(models.Model):
_inherit = "hr.employee"

@api.multi
@api.depends(
"job_id"
)
def _compute_job_grade(self):
for employee in self:
result = False
if employee.job_id:
result = employee.job_id.job_grade_ids.ids
employee.allowed_job_grade_ids = result

job_grade_id = fields.Many2one(
string="Job Grade",
comodel_name="hr.job_grade",
required=False,
)
allowed_job_grade_ids = fields.Many2many(
string="Job Grades",
comodel_name="hr.job_grade",
compute="_compute_job_grade",
store=False,
)
75 changes: 75 additions & 0 deletions hr_job_family_modelling/models/hr_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-
# Copyright 2018-2019 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models, fields, api


class HrJob(models.Model):
_inherit = "hr.job"

@api.multi
@api.depends(
"job_family_level_id"
)
def _compute_job_grade(self):
for job in self:
result = False
if job.job_family_level_id:
result = job.job_family_level_id.job_grade_ids.ids
job.allowed_job_grade_ids = result

job_family_level_id = fields.Many2one(
string="Job Family Level",
comodel_name="hr.job_family_level",
)
allowed_job_grade_ids = fields.Many2many(
string="Job Grades",
comodel_name="hr.job_grade",
compute="_compute_job_grade",
store=False,
)
job_grade_ids = fields.Many2many(
string="Job Grades",
comodel_name="hr.job_grade",
relation="rel_job_2_grade",
column1="job_id",
column2="job_grade_id",
)

@api.multi
def onchange_job_family_level_id(self, job_family_level_id):
value = self._get_value_before_onchange_job_family_level_id()
domain = self._get_domain_before_onchange_job_family_level_id()

if job_family_level_id:
obj_job_family_level = self.env["hr.job_family_level"]
job_family_level = obj_job_family_level.browse(
[job_family_level_id])[0]
value = self._get_value_after_onchange_job_family_level_id(
job_family_level
)
domain = self._get_domain_after_onchange_job_family_level_id(
job_family_level
)
return {"value": value, "domain": domain}

@api.multi
def _get_value_before_onchange_job_family_level_id(self):
return {
"job_grade_ids": [],
}

@api.multi
def _get_domain_before_onchange_job_family_level_id(self):
return {}

@api.multi
def _get_value_after_onchange_job_family_level_id(self, job_family_level):
return {
"job_grade_ids": [],
}

@api.multi
def _get_domain_after_onchange_job_family_level_id(self, job_family_level):
return {}
85 changes: 85 additions & 0 deletions hr_job_family_modelling/models/hr_job_family.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2019 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models, fields, api, _
from odoo.exceptions import Warning as UserError


class HrJobFamily(models.Model):
_name = "hr.job_family"
_description = "Job Family"

@api.multi
@api.depends(
"min_job_grade_id",
"max_job_grade_id",
"max_job_grade_id.sequence",
"min_job_grade_id.sequence",
)
def _compute_job_grade_ids(self):
obj_jg = self.env["hr.job_grade"]
job_grade_ids = obj_jg.search([]).ids
for jf in self:
result = []
if jf.min_job_grade_id and jf.max_job_grade_id:
min_job_grade_id = jf.min_job_grade_id.id
max_job_grade_id = jf.max_job_grade_id.id
min_index = job_grade_ids.index(min_job_grade_id)
max_index = job_grade_ids.index(max_job_grade_id)
result = job_grade_ids[min_index:max_index + 1]
jf.job_grade_ids = result

name = fields.Char(
string="Job Family",
required=True,
translate=True,
)
code = fields.Char(
string="Code",
required=True,
)
min_job_grade_id = fields.Many2one(
string="Min. Grade",
comodel_name="hr.job_grade",
required=True,
)
max_job_grade_id = fields.Many2one(
string="Max. Grade",
comodel_name="hr.job_grade",
required=True,
)
job_grade_ids = fields.Many2many(
string="Job Grades",
comodel_name="hr.job_grade",
relation="rel_job_family_2_grade",
column1="job_family_id",
column2="job_grade_id",
compute="_compute_job_grade_ids",
store=True,
readonly=True,
)
active = fields.Boolean(
string="Active",
default=True,
)
note = fields.Text(
string="Note",
)

@api.constrains(
"min_job_grade_id",
"max_job_grade_id",
)
def _check_min_max_grade(self):
obj_jg = self.env["hr.job_grade"]
job_grade_ids = obj_jg.search([]).ids
msg = _("Wrong Max Min Grade")
for jf in self:
if jf.min_job_grade_id and jf.max_job_grade_id:
min_job_grade_id = jf.min_job_grade_id.id
max_job_grade_id = jf.max_job_grade_id.id
min_index = job_grade_ids.index(min_job_grade_id)
max_index = job_grade_ids.index(max_job_grade_id)
if min_index > max_index:
raise UserError(msg)
27 changes: 27 additions & 0 deletions hr_job_family_modelling/models/hr_job_family_grade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Copyright 2018-2019 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models, fields


class HrJobFamilyGrade(models.Model):
_name = "hr.job_family_grade"
_description = "Job Family Grade"

name = fields.Char(
string="Job Family Grade",
required=True,
translate=True,
)
code = fields.Char(
string="Code",
required=True,
)
active = fields.Boolean(
string="Active",
default=True,
)
note = fields.Text(
string="Note",
)
Loading