Files
odoo_source/addons/hr/wizard/hr_plan_wizard.py
T
Philippe Wauthy 08a5bf761f [IMP] hr_*, sms: improve ux
Reorder smart buttons on the hr_employee to have them in the following order:
1. Documents
2. Holiday status
3. Time Off
4. Planning
5. Timesheets
6. Equipments
7. Cars
8. Contracts
9. Appraisal
10. Work Entries
11. Payroll
12. Attendance
13. Extra Hours

- Log in the chatter the name of the plan that has been started via the button "Launch Plan"

- When on mobile, open the Time Off Calendar in month view

- When sending a sms without any message, only display Message once in the invalid fields

- Avoid the sms-help info disappearing when clicking on it and there are characters in the body of the message

- Update the tooltip of phone number in the send sms wizard

- Avoid the employee name to be displayed on two lines on mobile if the name is too long. Reduce the font size instead

task-2735679

closes odoo/odoo#83745

Related: odoo/enterprise#23886
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-03-02 18:45:59 +00:00

47 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models, _
class HrPlanWizard(models.TransientModel):
_name = 'hr.plan.wizard'
_description = 'Plan Wizard'
def _default_plan_id(self):
employee = self.env['hr.employee'].browse(self.env.context.get('active_id'))
return self.env['hr.plan'].search([('company_id', '=', employee.company_id.id)], limit=1)
plan_id = fields.Many2one('hr.plan', default=_default_plan_id, domain="[('company_id', '=', company_id)]")
employee_id = fields.Many2one(
'hr.employee', string='Employee', required=True,
default=lambda self: self.env.context.get('active_id', None),
)
company_id = fields.Many2one(related='employee_id.company_id')
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
)
for plan in self:
plan.employee_id.message_post(body=_('The plan %s has been started', plan.plan_id.name))
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")],
}