fine-tuning of bf8a9af1ac549be830bec28c88eb1c565b591941 - Employees > Configuration > Activity Planning > Plans and ensure the activities have different responsible; - Create a new Employee, assign a Manager (a different user then the one connected, you can assign Marc Demo for example); - Click launch plan. Before this commit, the activity type responsible is ignored and the responsible for all activities is the connected user. Now, the responsible for the activities are assigned taking into account the activity type configuration. opw-2265631 closes odoo/odoo#54054 X-original-commit: 0f4ec369dccdf25aed259ae97b5cc8973a1a8c5a Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
# -*- 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'
|
|
|
|
@api.model
|
|
def default_get(self, fields_list):
|
|
res = super(HrPlanWizard, self).default_get(fields_list)
|
|
if (not fields_list or 'employee_id' in fields_list) and 'employee_id' not in res:
|
|
if self.env.context.get('active_id'):
|
|
res['employee_id'] = self.env.context['active_id']
|
|
return res
|
|
|
|
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_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):
|
|
activity = 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
|
|
)
|
|
activity._onchange_activity_type_id()
|
|
activity.user_id = responsible.id
|
|
|
|
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")],
|
|
}
|