[IMP] hr_fleet: improve the employer On/Offboarding plan activities

PURPOSE:
Companies want to have a better integration, we need to focus on the On/Offboarding process,
 to find automation and something to show to our customers.

In this commit, we add the "Fleet Manager" in the responsible list of the activities
generated from a plan.

Case 1:
 If employee is not linked with fleet, `Employee XXX is not linked to a vehicle`
 this  warning will be appeared.

Case 2:
 If employee linked with  fleet  but doesn't  fleet manager set  on fleet,
`Employee's vehicle XXX is not linked to a fleet manager.` this warning will be appeared.

task-3081261

closes odoo/odoo#108892

Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
Rohitkumar (roku)
2023-03-07 18:02:31 +01:00
parent e83ad17d51
commit 99b09bcd42
4 changed files with 44 additions and 0 deletions
+1
View File
@@ -13,6 +13,7 @@
'views/fleet_vehicle_views.xml',
'views/fleet_vehicle_cost_views.xml',
'wizard/hr_departure_wizard_views.xml',
'data/hr_fleet_data.xml',
],
'demo': [
'data/hr_fleet_demo.xml',
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="onboarding_fleet_training" model="hr.plan.activity.type">
<field name="summary">Fleet Training</field>
<field name="responsible">fleet_manager</field>
<field name="plan_id" ref="hr.onboarding_plan"/>
</record>
<record id="offboarding_fleet" model="hr.plan.activity.type">
<field name="summary">Take Back Fleet</field>
<field name="responsible">fleet_manager</field>
<field name="plan_id" ref="hr.offboarding_plan"/>
</record>
</data>
</odoo>
+1
View File
@@ -8,3 +8,4 @@ from . import fleet_vehicle
from . import fleet_vehicle_log_contract
from . import fleet_vehicle_log_services
from . import fleet_vehicle_odometer
from . import hr_plan_activity_type
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models, _
class HrPlanActivityType(models.Model):
_inherit = 'hr.plan.activity.type'
responsible = fields.Selection(selection_add=[('fleet_manager', "Fleet Manager"), ('employee',)], ondelete={'fleet_manager': 'set default'})
def get_responsible_id(self, employee):
if self.responsible == 'fleet_manager':
employee_id = self.env['hr.employee'].browse(employee._origin.id)
vehicle = employee_id.car_ids[:1]
warning = False
if not vehicle:
warning = _('Employee %s is not linked to a vehicle.', employee_id.name)
if vehicle and not vehicle.manager_id:
warning = _("Employee's vehicle %s is not linked to a fleet manager.", employee_id.name)
return {
'responsible': vehicle.manager_id,
'warning': warning,
}
return super().get_responsible_id(employee)