summaryrefslogtreecommitdiff
path: root/addons/hr/wizard
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/hr/wizard
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/hr/wizard')
-rw-r--r--addons/hr/wizard/__init__.py5
-rw-r--r--addons/hr/wizard/hr_departure_wizard.py34
-rw-r--r--addons/hr/wizard/hr_departure_wizard_views.xml35
-rw-r--r--addons/hr/wizard/hr_plan_wizard.py38
-rw-r--r--addons/hr/wizard/hr_plan_wizard_views.xml30
5 files changed, 142 insertions, 0 deletions
diff --git a/addons/hr/wizard/__init__.py b/addons/hr/wizard/__init__.py
new file mode 100644
index 00000000..09e60238
--- /dev/null
+++ b/addons/hr/wizard/__init__.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import hr_plan_wizard
+from . import hr_departure_wizard
diff --git a/addons/hr/wizard/hr_departure_wizard.py b/addons/hr/wizard/hr_departure_wizard.py
new file mode 100644
index 00000000..af861927
--- /dev/null
+++ b/addons/hr/wizard/hr_departure_wizard.py
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, fields, models
+
+
+class HrDepartureWizard(models.TransientModel):
+ _name = 'hr.departure.wizard'
+ _description = 'Departure Wizard'
+
+ departure_reason = fields.Selection([
+ ('fired', 'Fired'),
+ ('resigned', 'Resigned'),
+ ('retired', 'Retired')
+ ], string="Departure Reason", default="fired")
+ departure_description = fields.Text(string="Additional Information")
+ departure_date = fields.Date(string="Departure Date", required=True, default=fields.Date.today)
+ employee_id = fields.Many2one(
+ 'hr.employee', string='Employee', required=True,
+ default=lambda self: self.env.context.get('active_id', None),
+ )
+ archive_private_address = fields.Boolean('Archive Private Address', default=True)
+
+ def action_register_departure(self):
+ employee = self.employee_id
+ employee.departure_reason = self.departure_reason
+ employee.departure_description = self.departure_description
+ employee.departure_date = self.departure_date
+
+ if self.archive_private_address:
+ # ignore contact links to internal users
+ private_address = employee.address_home_id
+ if private_address and private_address.active and not self.env['res.users'].search([('partner_id', '=', private_address.id)]):
+ private_address.toggle_active()
diff --git a/addons/hr/wizard/hr_departure_wizard_views.xml b/addons/hr/wizard/hr_departure_wizard_views.xml
new file mode 100644
index 00000000..22b3b2b7
--- /dev/null
+++ b/addons/hr/wizard/hr_departure_wizard_views.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <data>
+ <record id="hr_departure_wizard_view_form" model="ir.ui.view">
+ <field name="name">hr.departure.wizard.view.form</field>
+ <field name="model">hr.departure.wizard</field>
+ <field name="arch" type="xml">
+ <form>
+ <sheet>
+ <group id="info" string="Departure Info">
+ <field name="employee_id" invisible="1"/>
+ <field name="departure_reason"/>
+ <field name="departure_description"/>
+ <field name="archive_private_address"/>
+ </group>
+ <group id="date" string="Departure Date">
+ <field name="departure_date" />
+ </group>
+ </sheet>
+ <footer>
+ <button name="action_register_departure" string="Save" type="object" class="oe_highlight"/>
+ <button string="Only Employee" class="btn-secondary" special="cancel"/>
+ </footer>
+ </form>
+ </field>
+ </record>
+
+ <record id="hr_departure_wizard_action" model="ir.actions.act_window">
+ <field name="name">Register Departure</field>
+ <field name="res_model">hr.departure.wizard</field>
+ <field name="view_mode">form</field>
+ <field name="target">new</field>
+ </record>
+ </data>
+</odoo>
diff --git a/addons/hr/wizard/hr_plan_wizard.py b/addons/hr/wizard/hr_plan_wizard.py
new file mode 100644
index 00000000..69e1ee28
--- /dev/null
+++ b/addons/hr/wizard/hr_plan_wizard.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, fields, models
+
+
+class HrPlanWizard(models.TransientModel):
+ _name = 'hr.plan.wizard'
+ _description = 'Plan Wizard'
+
+ plan_id = fields.Many2one('hr.plan', default=lambda self: self.env['hr.plan'].search([], limit=1))
+ employee_id = fields.Many2one(
+ 'hr.employee', string='Employee', required=True,
+ default=lambda self: self.env.context.get('active_id', None),
+ )
+
+ def action_launch(self):
+ for activity_type in self.plan_id.plan_activity_type_ids:
+ responsible = activity_type.get_responsible_id(self.employee_id)
+
+ if self.env['hr.employee'].with_user(responsible).check_access_rights('read', raise_exception=False):
+ date_deadline = self.env['mail.activity']._calculate_date_deadline(activity_type.activity_type_id)
+ self.employee_id.activity_schedule(
+ activity_type_id=activity_type.activity_type_id.id,
+ summary=activity_type.summary,
+ note=activity_type.note,
+ user_id=responsible.id,
+ date_deadline=date_deadline
+ )
+
+ return {
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'hr.employee',
+ 'res_id': self.employee_id.id,
+ 'name': self.employee_id.display_name,
+ 'view_mode': 'form',
+ 'views': [(False, "form")],
+ }
diff --git a/addons/hr/wizard/hr_plan_wizard_views.xml b/addons/hr/wizard/hr_plan_wizard_views.xml
new file mode 100644
index 00000000..0dfe92cf
--- /dev/null
+++ b/addons/hr/wizard/hr_plan_wizard_views.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <data>
+ <record id="plan_wizard" model="ir.ui.view">
+ <field name="name">plan wizard</field>
+ <field name="model">hr.plan.wizard</field>
+ <field name="arch" type="xml">
+ <form>
+ <sheet>
+ <group>
+ <field name="plan_id"/>
+ <field name="employee_id" invisible="1"/>
+ </group>
+ </sheet>
+ <footer>
+ <button name="action_launch" string="Launch Plan" type="object" class="oe_highlight" groups="hr.group_hr_manager"/>
+ <button string="Cancel" class="btn-secondary" special="cancel"/>
+ </footer>
+ </form>
+ </field>
+ </record>
+
+ <record id="plan_wizard_action" model="ir.actions.act_window">
+ <field name="name">Launch Plan</field>
+ <field name="res_model">hr.plan.wizard</field>
+ <field name="view_mode">form</field>
+ <field name="target">new</field>
+ </record>
+ </data>
+</odoo>