Skip to content

Commit

Permalink
[IMP] hr_employee_departure_reason: pre-commit stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
oihane committed Jun 27, 2024
1 parent d075f75 commit 65a3573
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 44 deletions.
6 changes: 3 additions & 3 deletions hr_employee_departure_reason/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

==========================
Hr employee departure reason
==========================
=========================
Employee departure reason
=========================

* New object employee departure reason in employee.

Expand Down
10 changes: 5 additions & 5 deletions hr_employee_departure_reason/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright 2021 Berezi - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Hr Employee Departure Reason",
'version': '14.0.1.0.0',
"name": "Employee departure reason",
"version": "14.0.1.0.0",
"author": "Avanzosc",
"website": "https://www.avanzosc.es",
"website": "https://github.com/avanzosc/hr-addons",
"category": "Human Resources/Employees",
"depends": [
"hr",
Expand All @@ -13,8 +13,8 @@
"security/ir.model.access.csv",
"data/hr_employee_departure_reason.xml",
"views/hr_employee_departure_reason.xml",
"wizard/hr_departure_wizard_views.xml"
"wizard/hr_departure_wizard_views.xml",
],
"license": "AGPL-3",
'installable': True,
"installable": True,
}
30 changes: 22 additions & 8 deletions hr_employee_departure_reason/data/hr_employee_departure_reason.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
<odoo>
<data noupdate="1">
<record forcecreate="True" id="contract_expiration" model="hr.employee.departure.reason">
<odoo noupdate="1">
<record
forcecreate="True"
id="contract_expiration"
model="hr.employee.departure.reason"
>
<field name="name">Contract Expiration</field>
</record>
<record forcecreate="True" id="not_passed" model="hr.employee.departure.reason">
<field name="name">Failed The Probationary Period</field>
</record>
<record forcecreate="True" id="resignation_within_period" model="hr.employee.departure.reason">
<field name="name">Voluntary Resignation Within The Probationary Period</field>
<record
forcecreate="True"
id="resignation_within_period"
model="hr.employee.departure.reason"
>
<field
name="name"
>Voluntary Resignation Within The Probationary Period</field>
</record>
<record forcecreate="True" id="resignation_outside_period" model="hr.employee.departure.reason">
<field name="name">Voluntary Resignation Outside The Probationary Period</field>
<record
forcecreate="True"
id="resignation_outside_period"
model="hr.employee.departure.reason"
>
<field
name="name"
>Voluntary Resignation Outside The Probationary Period</field>
</record>
<record forcecreate="True" id="dismissed" model="hr.employee.departure.reason">
<field name="name">Dismissed</field>
</record>
<record forcecreate="True" id="other" model="hr.employee.departure.reason">
<field name="name">Other Reasons</field>
</record>
</data>
</odoo>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright 2021 Berezi - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models, fields
from odoo import fields, models


class HrEmployeeDepartureReason(models.Model):
_name = 'hr.employee.departure.reason'
_description = 'Employee Departure Reason'
_name = "hr.employee.departure.reason"
_description = "Employee Departure Reason"

name = fields.Char(string='Employee Departure Reason')
name = fields.Char(string="Employee Departure Reason")
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# Copyright (c) 2021 Berezi Amubieta - Avanzosc S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tests import common
from odoo.exceptions import ValidationError
from odoo.tests import common


class TestHrEmployeeDepartureReason(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestHrEmployeeDepartureReason, cls).setUpClass()
cls.wizard_obj = cls.env['hr.departure.wizard']
cls.employee_obj = cls.env['hr.employee']
cls.wizard_obj = cls.env["hr.departure.wizard"]
cls.employee_obj = cls.env["hr.employee"]
cls.employee = cls.employee_obj.search([], limit=1)

def test_hr_departure_wizard(self):
wizard = self.wizard_obj.with_context(
active_id=self.employee.id).create({})
wizard = self.wizard_obj.with_context(active_id=self.employee.id).create({})
with self.assertRaises(ValidationError):
wizard.action_register_departure()
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="view_hr_employee_departure_reason_tree" model="ir.ui.view">
<field name="name">hr.employee.departure.reason.tree</field>
<field name="model">hr.employee.departure.reason</field>
<field name="arch" type="xml">
<tree string="Employee Departure Reason" editable="bottom">
<field name="name"/>
<tree editable="bottom">
<field name="name" />
</tree>
</field>
</record>
Expand All @@ -21,9 +20,12 @@
<field name="context">{}</field>
</record>

<menuitem id="menu_hr_employee_departure_reason"
action="action_hr_employee_departure_reason"
name="Employee departure reason" parent="hr.menu_human_resources_configuration"
sequence="0"/>
<menuitem
id="menu_hr_employee_departure_reason"
action="action_hr_employee_departure_reason"
name="Employee departure reason"
parent="hr.menu_human_resources_configuration"
sequence="0"
/>

</odoo>
15 changes: 8 additions & 7 deletions hr_employee_departure_reason/wizard/hr_departure_wizard.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# Copyright 2021 Berezi - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import fields, models, _
from odoo import _, fields, models
from odoo.exceptions import ValidationError


class HrDepartureWizard(models.TransientModel):
_inherit = 'hr.departure.wizard'
_inherit = "hr.departure.wizard"

departure_reason_id = fields.Many2one(
string='Employee Departure Reason',
comodel_name='hr.employee.departure.reason')
departure_observation = fields.Char(
string='Departure Observation')
string="Employee Departure Reason",
comodel_name="hr.employee.departure.reason",
)
departure_observation = fields.Char(string="Departure Observation")

def action_register_departure(self):
result = super(HrDepartureWizard, self).action_register_departure()
if not self.departure_reason_id:
raise ValidationError(
_("You must introduce the employee departure reason."))
_("You must introduce the employee departure reason.")
)
return result
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="hr_departure_wizard_view_form" model="ir.ui.view">
<field name="model">hr.departure.wizard</field>
<field name="inherit_id" ref="hr.hr_departure_wizard_view_form"/>
<field name="inherit_id" ref="hr.hr_departure_wizard_view_form" />
<field name="arch" type="xml">
<field name="departure_reason" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name="departure_description" position="before">
<field name="departure_reason_id"/>
<field name="departure_observation"/>
<field name="departure_reason_id" />
<field name="departure_observation" />
</field>
</field>
</record>
Expand Down

0 comments on commit 65a3573

Please sign in to comment.