Skip to content

Commit

Permalink
[8.0.1.8.0] hr_career_transition
Browse files Browse the repository at this point in the history
* Add option to change wage on each transition
  • Loading branch information
andhit-r committed Dec 12, 2019
1 parent f0a6657 commit e3152be
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hr_career_transition/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# pylint: disable=locally-disabled, manifest-required-author
{
"name": "Career Transition",
"version": "8.0.1.7.0",
"version": "8.0.1.8.0",
"category": "Human Resource",
"website": "https://opensynergy-indonesia.com",
"author": "OpenSynergy Indonesia",
Expand Down
27 changes: 26 additions & 1 deletion hr_career_transition/models/hr_career_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,15 @@ def _default_employee_id(self):
],
},
)
new_wage = fields.Float(
string="New Wage",
readonly=True,
states={
"draft": [
("readonly", False),
],
},
)
# Previous Data
previous_company_id = fields.Many2one(
string="Previous Company",
Expand All @@ -254,6 +263,9 @@ def _default_employee_id(self):
string="Previous Working Schedule",
comodel_name="resource.calendar",
)
previous_wage = fields.Float(
string="Previous Wage",
)
# Data Change Policy
change_company = fields.Boolean(
related="type_id.change_company",
Expand All @@ -275,6 +287,11 @@ def _default_employee_id(self):
string="Change Working Schedule",
readonly=True,
)
change_wage = fields.Boolean(
related="type_id.change_wage",
string="Change Wage",
readonly=True,
)

note = fields.Text(
string="Note",
Expand Down Expand Up @@ -489,6 +506,10 @@ def onchange_new_job_id(self):
def onchange_new_working_hour_id(self):
self.new_working_hour_id = self.previous_working_hour_id

@api.onchange("previous_wage")
def onchange_new_wage(self):
self.new_wage = self.previous_wage

@api.multi
def onchange_previous_contract(self, previous_contract_id):
value = self._get_value_before_onchange_previous_contract()
Expand All @@ -510,6 +531,7 @@ def _get_value_before_onchange_previous_contract(self):
"previous_job_id": False,
"previous_department_id": False,
"previous_company_id": False,
"previous_wage": 0.0,
}

@api.multi
Expand All @@ -524,6 +546,7 @@ def _get_value_after_onchange_previous_contract(
"previous_job_id": previous_contract.job_id,
"previous_department_id": previous_contract.contract_department_id,
"previous_company_id": previous_contract.company_id,
"previous_wage": previous_contract.wage,
}

@api.multi
Expand Down Expand Up @@ -559,7 +582,7 @@ def _prepare_new_contract(self):
"working_hours": self.new_working_hour_id and \
self.new_working_hour_id.id or \
False,
"wage": 0.0,
"wage": self.new_wage,
"contract_department_id": self.new_department_id and \
self.new_department_id.id or \
False,
Expand All @@ -584,6 +607,7 @@ def _prepare_contract_update(self):
"company_id": self.new_company_id and
self.new_company_id.id or
False,
"wage": self.new_wage,
}

@api.multi
Expand All @@ -602,6 +626,7 @@ def _prepare_contract_revert(self):
"company_id": self.previous_company_id and
self.previous_company_id.id or
False,
"wage": self.previous_wage,
}

@api.multi
Expand Down
3 changes: 3 additions & 0 deletions hr_career_transition/models/hr_career_transition_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class HrCareerTransitionType(models.Model):
change_working_schedule = fields.Boolean(
string="Change Working Schedule",
)
change_wage = fields.Boolean(
string="Change Wage",
)

sequence_id = fields.Many2one(
string="Sequence",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<field name="change_job_title"/>
<field name="change_department"/>
<field name="change_working_schedule"/>
<field name="change_wage"/>
</group>
</page>
<page name="reason" string="Reasons">
Expand Down
4 changes: 4 additions & 0 deletions hr_career_transition/views/hr_career_transition_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
<field name="previous_working_hour_id" string="Working Schedule" readonly="1"/>
<field name="new_working_hour_id" nolabel="1"
attrs="{'required':[('change_working_schedule','=',True)], 'readonly':[('change_working_schedule','=',False)]}"/>
<field name="previous_wage" string="Basic Salary" readonly="1"/>
<field name="new_wage" nolabel="1"
attrs="{'required':[('change_wage','=',True)], 'readonly':[('change_wage','=',False)]}"/>
</group>
</page>
<page name="note" string="Note">
Expand All @@ -83,6 +86,7 @@
<field name="change_department"/>
<field name="change_job_title"/>
<field name="change_working_schedule"/>
<field name="change_wage"/>
</group>
<group name="group_policy_2" colspan="4" col="2">
<field name="confirm_ok"/>
Expand Down

0 comments on commit e3152be

Please sign in to comment.