Skip to content

Commit

Permalink
[8.0.1.0.0] hr_employee_job_family_from_contract
Browse files Browse the repository at this point in the history
  • Loading branch information
andhit-r committed Mar 16, 2019
1 parent cf5bb75 commit efa353e
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 0 deletions.
39 changes: 39 additions & 0 deletions hr_employee_job_family_from_contract/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

=================================
Employee Job Family From Contract
=================================



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 *Employee Job Family From Contract*
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.
5 changes: 5 additions & 0 deletions hr_employee_job_family_from_contract/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2019 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
20 changes: 20 additions & 0 deletions hr_employee_job_family_from_contract/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Copyright 2019 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# pylint: disable=locally-disabled, manifest-required-author
{
"name": "Employee Job Family From Contract",
"version": "8.0.1.0.0",
"category": "Human Resource",
"website": "https://opensynergy-indonesia.com",
"author": "OpenSynergy Indonesia",
"license": "AGPL-3",
"installable": True,
"depends": [
"hr_employee_data_from_contract",
"hr_job_family_modelling",
],
"data": [
"views/hr_contract_views.xml",
],
}
8 changes: 8 additions & 0 deletions hr_employee_job_family_from_contract/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright 2019 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

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

from openerp import models, fields, api


class HrContract(models.Model):
_inherit = "hr.contract"

@api.multi
@api.depends(
"job_id"
)
def _compute_job_grade(self):
for contract in self:
result = False
if contract.job_id:
result = contract.job_id.job_grade_ids.ids
contract.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,
)

@api.onchange("job_id")
def onchange_job_grade_id(self):
self.job_grade_id = False
18 changes: 18 additions & 0 deletions hr_employee_job_family_from_contract/models/hr_employee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2019 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, fields


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

job_grade_id = fields.Many2one(
string="Job Grade",
comodel_name="hr.job_grade",
required=False,
related="current_contract_id.job_grade_id",
store=True,
readonly=True,
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions hr_employee_job_family_from_contract/views/hr_contract_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2019 OpenSynergy Indonesia
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<openerp>
<data>
<record id="hr_contract_view_form" model="ir.ui.view">
<field name="name">hr.contract form</field>
<field name="model">hr.contract</field>
<field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='job_id']" position="after">
<field name="allowed_job_grade_ids" widget="many2many_tags" groups="base.group_system"/>
<field name="job_grade_id" domain="[('id','in',allowed_job_grade_ids[0][2])]"/>
</xpath>
</data>
</field>
</record>


</data>
</openerp>

0 comments on commit efa353e

Please sign in to comment.