[IMP] Time Off: Year Calendar ajustments
A new calendar view has been added, the "year" view. Some modifications should be done on this view, more specialy in "Time Off" application. Problems were the fact that it was hard to see if a time off has been approved or not. Another was the fact that week-ends & public holidays were not grey. This commit change year calendar in Time Off module. More specially, this commit: - Change default calendar in personal dashboard to "year" - Gray week-ends & public holiday (based on the worker's calendar) - Hatch non-approved time off - Removed a calendar view from My Time Off Requests - Fix a "cancel" button that doesn't work - Add a new view that is displayed when there is no filter to show on the filter view for calendars Task id #2318645 Task id #2317525
This commit is contained in:
committed by
Yannick Tivisse
parent
6cfec48ba4
commit
ec25487cfb
@@ -256,6 +256,8 @@ class HolidaysRequest(models.Model):
|
||||
request_unit_half = fields.Boolean('Half Day', compute='_compute_request_unit_half', store=True, readonly=False)
|
||||
request_unit_hours = fields.Boolean('Custom Hours', compute='_compute_request_unit_hours', store=True, readonly=False)
|
||||
request_unit_custom = fields.Boolean('Days-long custom hours', compute='_compute_request_unit_custom', store=True, readonly=False)
|
||||
# view
|
||||
is_hatched = fields.Boolean('Hatched', compute='_compute_is_hatched')
|
||||
|
||||
_sql_constraints = [
|
||||
('type_value',
|
||||
@@ -282,7 +284,7 @@ class HolidaysRequest(models.Model):
|
||||
is_officer = self.user_has_groups('hr_holidays.group_hr_holidays_user')
|
||||
|
||||
for leave in self:
|
||||
if is_officer or leave.user_id == self.env.user or leave.manager_id == self.env.user:
|
||||
if is_officer or leave.user_id == self.env.user or leave.employee_id.leave_manager_id == self.env.user:
|
||||
leave.name = leave.sudo().private_name
|
||||
else:
|
||||
leave.name = '*****'
|
||||
@@ -291,7 +293,7 @@ class HolidaysRequest(models.Model):
|
||||
is_officer = self.user_has_groups('hr_holidays.group_hr_holidays_user')
|
||||
|
||||
for leave in self:
|
||||
if is_officer or leave.user_id == self.env.user or leave.manager_id == self.env.user:
|
||||
if is_officer or leave.user_id == self.env.user or leave.employee_id.leave_manager_id == self.env.user:
|
||||
leave.sudo().private_name = leave.name
|
||||
|
||||
def _search_description(self, operator, value):
|
||||
@@ -548,6 +550,11 @@ class HolidaysRequest(models.Model):
|
||||
else:
|
||||
holiday.can_approve = True
|
||||
|
||||
@api.depends('state')
|
||||
def _compute_is_hatched(self):
|
||||
for holiday in self:
|
||||
holiday.is_hatched = holiday.state not in ['refuse', 'validate']
|
||||
|
||||
@api.constrains('date_from', 'date_to', 'employee_id')
|
||||
def _check_date(self):
|
||||
for holiday in self.filtered('employee_id'):
|
||||
|
||||
@@ -229,7 +229,7 @@ class HolidaysAllocation(models.Model):
|
||||
is_officer = self.env.user.has_group('hr_holidays.group_hr_holidays_user')
|
||||
|
||||
for allocation in self:
|
||||
if is_officer or allocation.employee_id.user_id == self.env.user or allocation.manager_id == self.env.user:
|
||||
if is_officer or allocation.employee_id.user_id == self.env.user or allocation.employee_id.leave_manager_id == self.env.user:
|
||||
allocation.name = allocation.sudo().private_name
|
||||
else:
|
||||
allocation.name = '*****'
|
||||
@@ -237,7 +237,7 @@ class HolidaysAllocation(models.Model):
|
||||
def _inverse_description(self):
|
||||
is_officer = self.env.user.has_group('hr_holidays.group_hr_holidays_user')
|
||||
for allocation in self:
|
||||
if is_officer or allocation.employee_id.user_id == self.env.user or allocation.manager_id == self.env.user:
|
||||
if is_officer or allocation.employee_id.user_id == self.env.user or allocation.employee_id.leave_manager_id == self.env.user:
|
||||
allocation.sudo().private_name = allocation.name
|
||||
|
||||
def _search_description(self, operator, value):
|
||||
|
||||
@@ -28,6 +28,8 @@ class LeaveReportCalendar(models.Model):
|
||||
('validate', 'Approved')
|
||||
], readonly=True)
|
||||
|
||||
is_hatched = fields.Boolean('Hatched', readonly=True)
|
||||
|
||||
def init(self):
|
||||
tools.drop_view_if_exists(self._cr, 'hr_leave_report_calendar')
|
||||
self._cr.execute("""CREATE OR REPLACE VIEW hr_leave_report_calendar AS
|
||||
@@ -42,7 +44,8 @@ class LeaveReportCalendar(models.Model):
|
||||
CASE
|
||||
WHEN hl.holiday_type = 'employee' THEN rr.tz
|
||||
ELSE %s
|
||||
END AS tz
|
||||
END AS tz,
|
||||
state != 'validate' as is_hatched
|
||||
FROM hr_leave hl
|
||||
LEFT JOIN hr_employee em
|
||||
ON em.id = hl.employee_id
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<calendar string="Time Off" date_start="start_datetime" date_stop="stop_datetime" mode="month" quick_add="False" color="employee_id" event_open_popup="True" js_class="time_off_calendar_all" show_unusual_days="True">
|
||||
<field name="name"/>
|
||||
<field name="employee_id" filters="1" invisible="1"/>
|
||||
<field name="is_hatched" invisible="1"/>
|
||||
</calendar>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -138,6 +138,20 @@ odoo.define('hr_holidays.dashboard.view_custo', function(require) {
|
||||
var self = this;
|
||||
return this._super.apply(this, arguments).then(function () {
|
||||
self.$el.parent().find('.o_calendar_mini').hide();
|
||||
|
||||
// Check if there is a filter to display on the sidebar
|
||||
// If there is no filter, hide the sidebar
|
||||
const noFilters = !Object.values(self.state.filters).some(f => f.filters.length);
|
||||
|
||||
// Remove the no data sidebar
|
||||
self.$sidebar.find('#o_calendar_filter_no_data').remove();
|
||||
if (noFilters) {
|
||||
// Show a special sidebar
|
||||
self.$sidebar.html(QWeb.render('hr_holidays.calendar.sidebar.nofilter', {
|
||||
title: 'Time Off Type',
|
||||
description: '(no data)'
|
||||
}));
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -154,10 +168,14 @@ odoo.define('hr_holidays.dashboard.view_custo', function(require) {
|
||||
}).then(function (result) {
|
||||
self.$el.parent().find('.o_calendar_mini').hide();
|
||||
self.$el.parent().find('.o_timeoff_container').remove();
|
||||
var elem = QWeb.render('hr_holidays.dashboard_calendar_header', {
|
||||
timeoffs: result,
|
||||
});
|
||||
self.$el.before(elem);
|
||||
|
||||
// Do not display header if there is no element to display
|
||||
if (result.length > 0) {
|
||||
var elem = QWeb.render('hr_holidays.dashboard_calendar_header', {
|
||||
timeoffs: result,
|
||||
});
|
||||
self.$el.before(elem);
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
.o_timeoff_calendar .o_content {
|
||||
.o_timeoff_container {
|
||||
height: 6rem;
|
||||
|
||||
+ .o_calendar_container {
|
||||
height: calc(100% - 6rem);
|
||||
}
|
||||
}
|
||||
|
||||
.o_calendar_container {
|
||||
height: calc(100% - 6rem);
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
@include media-breakpoint-down(sm) {
|
||||
|
||||
@@ -75,4 +75,18 @@
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="hr_holidays.calendar.sidebar.nofilter">
|
||||
<div class="o_calendar_filter" id="o_calendar_filter_no_data">
|
||||
<h5 t-esc="title"/>
|
||||
<div class="o_calendar_filter_items">
|
||||
<div class="w-100 position-relative mb-2">
|
||||
<p class="d-flex align-items-center m-0">
|
||||
<t t-if="description" t-esc="description"/>
|
||||
<t t-else=""></t>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
|
||||
@@ -353,10 +353,11 @@
|
||||
<field name="name">hr.leave.view.dashboard</field>
|
||||
<field name="model">hr.leave</field>
|
||||
<field name="arch" type="xml">
|
||||
<calendar js_class="time_off_calendar" string="Time Off Request" form_view_id="%(hr_holidays.hr_leave_view_form_dashboard)d" event_open_popup="true" date_start="date_from" date_stop="date_to" mode="month" quick_add="False" show_unusual_days="True" color="holiday_status_id" hide_time="True">
|
||||
<calendar js_class="time_off_calendar" string="Time Off Request" form_view_id="%(hr_holidays.hr_leave_view_form_dashboard)d" event_open_popup="true" date_start="date_from" date_stop="date_to" mode="year" quick_add="False" show_unusual_days="True" color="holiday_status_id" hide_time="True">
|
||||
<field name="display_name"/>
|
||||
<field name="holiday_status_id" filters="1" invisible="1"/>
|
||||
<field name="state" invisible="1"/>
|
||||
<field name="is_hatched" invisible="1" />
|
||||
</calendar>
|
||||
</field>
|
||||
</record>
|
||||
@@ -432,10 +433,11 @@
|
||||
<field name="name">hr.leave.view.calendar</field>
|
||||
<field name="model">hr.leave</field>
|
||||
<field name="arch" type="xml">
|
||||
<calendar js_class="time_off_calendar_all" string="Time Off Request" event_open_popup="true" date_start="date_from" date_stop="date_to" mode="month" quick_add="False" color="employee_id">
|
||||
<calendar js_class="time_off_calendar_all" string="Time Off Request" form_view_id="%(hr_holidays.hr_leave_view_form_dashboard)d" event_open_popup="true" date_start="date_from" date_stop="date_to" mode="month" show_unusual_days="True" quick_add="False" color="employee_id">
|
||||
<field name="display_name"/>
|
||||
<field name="holiday_status_id" filters="1" invisible="1"/>
|
||||
<field name="employee_id" filters="1" invisible="1"/>
|
||||
<field name="is_hatched" invisible="1" />
|
||||
</calendar>
|
||||
</field>
|
||||
</record>
|
||||
@@ -605,7 +607,7 @@
|
||||
<field name="name">My Time Off Requests</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">hr.leave</field>
|
||||
<field name="view_mode">tree,form,calendar,kanban,activity</field>
|
||||
<field name="view_mode">tree,form,kanban,activity</field>
|
||||
<field name="context">{}</field>
|
||||
<field name="search_view_id" ref="hr_leave_view_search_my"/>
|
||||
<field name="domain">[('user_id', '=', uid)]</field>
|
||||
|
||||
Reference in New Issue
Block a user