summaryrefslogtreecommitdiff
path: root/addons/hr/wizard
diff options
context:
space:
mode:
authorRomainLibert <rli@odoo.com>2018-11-29 14:52:26 +0000
committerYannick Tivisse <yti@odoo.com>2018-12-18 11:20:54 +0000
commitd5fd84b89a51ef41ca0aa13cf7acc94e684d40ce (patch)
tree2753ec37157e97767212b2faca1b2c41b6d24f30 /addons/hr/wizard
parente230050562e1adc67a09590cf55690ac85a9f0da (diff)
[IMP] hr: add onboarding/offboarding activity plannings
Purpose ======= Give the possibility to elaborate plans through Odoo. For instance, in HR, you could create an onboarding plan when a employee is created. Someone manages laptop and other equipment, someone check hr stuff, ... This feature is generic but in a first time we will apply it only on the hr module. Ease HR process in a company by creating plans: a plan is an assembly of Next Activities that will be launched together whenever you need it. Example of plan for an employee onboarding: Activity: Prepare materials Responsible: Alain Deadline: At the contract signature Activity: Manage Cars Responsible: Cécile Deadline: at the contract signature (both signature) Activity: Plan Training Responsible: Caroline Deadline: After signature Activity: Training Responsible: Employee Deadline: 1 week after the employement date Specifications ============== On HR Configuration: Add a menu "Activity Plans" Activity plan object: - Name - Model (debug mode) (hr by default) - Activity Template o2m - Activity Type (only the one related to hr) - Deadline (come from Activity Type) - Responsible \/ 0 Coach 0 Manager 0 Other [Responsible_name] \/ (coach, manager or manually set if other) Add datas, 2 plans: Onboarding - Name: Onboarding - Plan lines: Activity: Setup IT Materials Responsible: [a user] (manager) Deadline: At the contract signature Activity: Plan Training Responsible: [manager] Deadline: After signature Activity: Training Responsible: [Employee] Deadline: 1 week after the employement date Offboarding - Name: Onboarding - Plan lines: Activity: Compute Out Delais Responsible: [a user] (manager) Deadline: today Activity: Take Back HR Materials Responsible: [manager] Deadline: today Activity: Manage Car Responsible: [manager] Deadline: today When to trigger it ? HR specific use case: 1/ On employee, from the employee chatter: when you create an employee, Odoobot will log a note with the following message: "Congratulations ! May i recommand you to setup an onboarding plan?", with a link create a plan from it. 2/ Add a button 'launch plan' to open a wizard to select the plan 3/ When archive an employee Open a wizard with: - Reason (selection) - Action plan (m2o not required) Error if employee not linked to a user. Task : 1912681 closes odoo/odoo#29151
Diffstat (limited to 'addons/hr/wizard')
-rw-r--r--addons/hr/wizard/__init__.py5
-rw-r--r--addons/hr/wizard/departure_wizard.py33
-rw-r--r--addons/hr/wizard/departure_wizard_views.xml32
-rw-r--r--addons/hr/wizard/plan_wizard.py35
-rw-r--r--addons/hr/wizard/plan_wizard_views.xml30
5 files changed, 135 insertions, 0 deletions
diff --git a/addons/hr/wizard/__init__.py b/addons/hr/wizard/__init__.py
new file mode 100644
index 00000000000..d2c87d24a36
--- /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 plan_wizard
+from . import departure_wizard
diff --git a/addons/hr/wizard/departure_wizard.py b/addons/hr/wizard/departure_wizard.py
new file mode 100644
index 00000000000..9efa96351c3
--- /dev/null
+++ b/addons/hr/wizard/departure_wizard.py
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import fields, models, _
+from odoo.exceptions import UserError
+
+
+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")
+ plan_id = fields.Many2one('hr.plan', default=lambda self: self.env['hr.plan'].search([], limit=1))
+
+ def action_register_departure(self):
+ active_id = self.env.context.get('active_id')
+
+ employee = self.env['hr.employee'].browse(active_id)
+ employee.departure_reason = self.departure_reason
+ employee.departure_description = self.departure_description
+
+ for activity_type in self.plan_id.plan_activity_type_ids:
+ self.env['mail.activity'].create({
+ 'res_id': employee.id,
+ 'res_model_id': self.env['ir.model']._get('hr.employee').id,
+ 'activity_type_id': activity_type.activity_type_id.id,
+ 'user_id': activity_type.get_responsible_id(employee).id,
+ })
diff --git a/addons/hr/wizard/departure_wizard_views.xml b/addons/hr/wizard/departure_wizard_views.xml
new file mode 100644
index 00000000000..4e0ca36abfe
--- /dev/null
+++ b/addons/hr/wizard/departure_wizard_views.xml
@@ -0,0 +1,32 @@
+<?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>
+ <field name="plan_id"/>
+ <field name="departure_reason"/>
+ <field name="departure_description"/>
+ </group>
+ </sheet>
+ <footer>
+ <button name="action_register_departure" string="Save" type="object" class="oe_highlight"/>
+ <button string="Cancel" 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_type">form</field>
+ <field name="view_mode">form</field>
+ <field name="target">new</field>
+ </record>
+ </data>
+</odoo>
diff --git a/addons/hr/wizard/plan_wizard.py b/addons/hr/wizard/plan_wizard.py
new file mode 100644
index 00000000000..b08428829ee
--- /dev/null
+++ b/addons/hr/wizard/plan_wizard.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import fields, models, _
+from odoo.exceptions import UserError
+
+
+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))
+
+ def launch(self):
+ active_id = self.env.context.get('active_id')
+
+ rec = self.env['hr.employee'].browse(active_id)
+
+ for activity_type in self.plan_id.plan_activity_type_ids:
+ self.env['mail.activity'].create({
+ 'res_id': rec.id,
+ 'res_model_id': self.env['ir.model']._get('hr.employee').id,
+ 'activity_type_id': activity_type.activity_type_id.id,
+ 'user_id': activity_type.get_responsible_id(rec).id,
+ })
+
+ return {
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'hr.employee',
+ 'res_id': active_id,
+ 'name': rec.display_name,
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'views': [(False, "form")],
+ }
diff --git a/addons/hr/wizard/plan_wizard_views.xml b/addons/hr/wizard/plan_wizard_views.xml
new file mode 100644
index 00000000000..b6829e17ea3
--- /dev/null
+++ b/addons/hr/wizard/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"/>
+ </group>
+ </sheet>
+ <footer>
+ <button name="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_type">form</field>
+ <field name="view_mode">form</field>
+ <field name="target">new</field>
+ </record>
+ </data>
+</odoo>