diff options
| -rw-r--r-- | addons/hr/data/hr_data.xml | 42 | ||||
| -rw-r--r-- | addons/hr/models/hr_plan.py | 16 | ||||
| -rw-r--r-- | addons/hr/views/hr_views.xml | 5 | ||||
| -rw-r--r-- | addons/hr/wizard/hr_departure_wizard.py | 17 | ||||
| -rw-r--r-- | addons/hr/wizard/hr_departure_wizard_views.xml | 1 | ||||
| -rw-r--r-- | addons/hr/wizard/hr_plan_wizard.py | 28 | ||||
| -rw-r--r-- | addons/hr/wizard/hr_plan_wizard_views.xml | 3 |
7 files changed, 52 insertions, 60 deletions
diff --git a/addons/hr/data/hr_data.xml b/addons/hr/data/hr_data.xml index 7436e422be6..869a74a8350 100644 --- a/addons/hr/data/hr_data.xml +++ b/addons/hr/data/hr_data.xml @@ -18,60 +18,28 @@ <field name="image" eval="obj(ref('base.partner_admin')).image" model="res.partner"/> </record> - <record id="activity_type_setup_it_materials" model="mail.activity.type"> - <field name="name">Setup IT Materials</field> - <field name="res_model_id" ref="hr.model_hr_employee"/> - </record> - - <record id="activity_type_setup_it_materials" model="mail.activity.type"> - <field name="name">Setup IT Materials</field> - <field name="res_model_id" ref="hr.model_hr_employee"/> - </record> - - <record id="activity_type_plan_training" model="mail.activity.type"> - <field name="name">Plan Training</field> - <field name="res_model_id" ref="hr.model_hr_employee"/> - </record> - - <record id="activity_type_training" model="mail.activity.type"> - <field name="name">Training</field> - <field name="res_model_id" ref="hr.model_hr_employee"/> - <field name="delay_unit">weeks</field> - <field name="delay_count">1</field> - </record> - - <record id="activity_type_compute_out_delais" model="mail.activity.type"> - <field name="name">Compute Out Delais</field> - <field name="res_model_id" ref="hr.model_hr_employee"/> - </record> - - <record id="activity_type_take_back_hr_materials" model="mail.activity.type"> - <field name="name">Take Back HR Materials</field> - <field name="res_model_id" ref="hr.model_hr_employee"/> - </record> - <record id="onboarding_setup_it_materials" model="hr.plan.activity.type"> - <field name="activity_type_id" ref="hr.activity_type_setup_it_materials"/> + <field name="summary">Setup IT Materials</field> <field name="responsible">manager</field> </record> <record id="onboarding_plan_training" model="hr.plan.activity.type"> - <field name="activity_type_id" ref="hr.activity_type_plan_training"/> + <field name="summary">Plan Training</field> <field name="responsible">manager</field> </record> <record id="onboarding_training" model="hr.plan.activity.type"> - <field name="activity_type_id" ref="hr.activity_type_training"/> + <field name="summary">Training</field> <field name="responsible">employee</field> </record> <record id="offboarding_setup_compute_out_delais" model="hr.plan.activity.type"> - <field name="activity_type_id" ref="hr.activity_type_compute_out_delais"/> + <field name="summary">Compute Out Delais</field> <field name="responsible">manager</field> </record> <record id="offboarding_take_back_hr_materials" model="hr.plan.activity.type"> - <field name="activity_type_id" ref="hr.activity_type_take_back_hr_materials"/> + <field name="summary">Take Back HR Materials</field> <field name="responsible">manager</field> </record> diff --git a/addons/hr/models/hr_plan.py b/addons/hr/models/hr_plan.py index fee13675130..fb999597398 100644 --- a/addons/hr/models/hr_plan.py +++ b/addons/hr/models/hr_plan.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models, _ +from odoo import api, fields, models, _ from odoo.exceptions import UserError @@ -9,9 +9,12 @@ class PlanActivityType(models.Model): _name = 'hr.plan.activity.type' _description = 'Plan activity type' - activity_type_id = fields.Many2one('mail.activity.type', 'Activity Type', - domain=lambda self: [('res_model_id', '=', self.env['ir.model']._get('hr.employee').id)]) - name = fields.Char(related='activity_type_id.name') + activity_type_id = fields.Many2one( + 'mail.activity.type', 'Activity Type', + default=lambda self: self.env.ref('mail.mail_activity_data_todo'), + domain=lambda self: ['|', ('res_model_id', '=', False), ('res_model_id', '=', self.env['ir.model']._get('hr.employee').id)] + ) + summary = fields.Char('Summary') responsible = fields.Selection([ ('coach', 'Coach'), ('manager', 'Manager'), @@ -19,6 +22,11 @@ class PlanActivityType(models.Model): ('other', 'Other')], default='employee', string='Responsible') responsible_id = fields.Many2one('res.users', 'Responsible Person') + @api.onchange('activity_type_id') + def _onchange_activity_type_id(self): + if self.activity_type_id and self.activity_type_id.summary and not self.summary: + self.summary = self.activity_type_id.summary + def get_responsible_id(self, employee_id): if self.responsible == 'coach': self.responsible_id = employee_id.coach_id.user_id diff --git a/addons/hr/views/hr_views.xml b/addons/hr/views/hr_views.xml index a175fb96811..3ba86ab5bba 100644 --- a/addons/hr/views/hr_views.xml +++ b/addons/hr/views/hr_views.xml @@ -76,7 +76,8 @@ <group string="Activities"> <field name="plan_activity_type_ids" nolabel="1"> <tree editable="bottom"> - <field name="name"/> + <field name="activity_type_id"/> + <field name="summary"/> <field name="responsible"/> <field name="responsible_id" attrs="{'readonly': [('responsible', '!=', 'other')]}"/> </tree> @@ -94,7 +95,7 @@ <form string="Planning"> <sheet> <group> - <field name="name"/> + <field name="summary"/> <field name="activity_type_id"/> <field name="responsible"/> <field name="responsible_id" attrs="{'invisible': [('responsible', '!=', 'other')]}"/> diff --git a/addons/hr/wizard/hr_departure_wizard.py b/addons/hr/wizard/hr_departure_wizard.py index 9efa96351c3..70405c5b04d 100644 --- a/addons/hr/wizard/hr_departure_wizard.py +++ b/addons/hr/wizard/hr_departure_wizard.py @@ -1,14 +1,21 @@ # -*- 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 +from odoo import api, fields, models class HrDepartureWizard(models.TransientModel): _name = 'hr.departure.wizard' _description = 'Departure Wizard' + @api.model + def default_get(self, fields): + res = super(HrDepartureWizard, self).default_get(fields) + if (not fields or 'employee_id' in fields) and 'employee_id' not in res: + if self.env.context.get('active_id'): + res['employee_id'] = self.env.context['active_id'] + return res + departure_reason = fields.Selection([ ('fired', 'Fired'), ('resigned', 'Resigned'), @@ -16,11 +23,10 @@ class HrDepartureWizard(models.TransientModel): ], 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)) + employee_id = fields.Many2one('hr.employee', string='Employee', required=True) def action_register_departure(self): - active_id = self.env.context.get('active_id') - - employee = self.env['hr.employee'].browse(active_id) + employee = self.employee_id employee.departure_reason = self.departure_reason employee.departure_description = self.departure_description @@ -29,5 +35,6 @@ class HrDepartureWizard(models.TransientModel): 'res_id': employee.id, 'res_model_id': self.env['ir.model']._get('hr.employee').id, 'activity_type_id': activity_type.activity_type_id.id, + 'summary': activity_type.summary, 'user_id': activity_type.get_responsible_id(employee).id, }) diff --git a/addons/hr/wizard/hr_departure_wizard_views.xml b/addons/hr/wizard/hr_departure_wizard_views.xml index 4e0ca36abfe..58679ba52cd 100644 --- a/addons/hr/wizard/hr_departure_wizard_views.xml +++ b/addons/hr/wizard/hr_departure_wizard_views.xml @@ -9,6 +9,7 @@ <sheet> <group> <field name="plan_id"/> + <field name="employee_id" invisible="1"/> <field name="departure_reason"/> <field name="departure_description"/> </group> diff --git a/addons/hr/wizard/hr_plan_wizard.py b/addons/hr/wizard/hr_plan_wizard.py index b08428829ee..654484f431c 100644 --- a/addons/hr/wizard/hr_plan_wizard.py +++ b/addons/hr/wizard/hr_plan_wizard.py @@ -1,34 +1,40 @@ # -*- 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 +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)) - - def launch(self): - active_id = self.env.context.get('active_id') + @api.model + def default_get(self, fields): + res = super(HrPlanWizard, self).default_get(fields) + if (not fields or 'employee_id' in fields) and 'employee_id' not in res: + if self.env.context.get('active_id'): + res['employee_id'] = self.env.context['active_id'] + return res - rec = self.env['hr.employee'].browse(active_id) + 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) + @api.multi + def action_launch(self): for activity_type in self.plan_id.plan_activity_type_ids: self.env['mail.activity'].create({ - 'res_id': rec.id, + 'res_id': self.employee_id.id, 'res_model_id': self.env['ir.model']._get('hr.employee').id, + 'summary': activity_type.summary, 'activity_type_id': activity_type.activity_type_id.id, - 'user_id': activity_type.get_responsible_id(rec).id, + 'user_id': activity_type.get_responsible_id(self.employee_id).id, }) return { 'type': 'ir.actions.act_window', 'res_model': 'hr.employee', - 'res_id': active_id, - 'name': rec.display_name, + 'res_id': self.employee_id.id, + 'name': self.employee_id.display_name, 'view_type': 'form', '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 index b6829e17ea3..592759bb631 100644 --- a/addons/hr/wizard/hr_plan_wizard_views.xml +++ b/addons/hr/wizard/hr_plan_wizard_views.xml @@ -9,10 +9,11 @@ <sheet> <group> <field name="plan_id"/> + <field name="employee_id" invisible="1"/> </group> </sheet> <footer> - <button name="launch" string="Launch Plan" type="object" class="oe_highlight" groups="hr.group_hr_manager"/> + <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> |
