diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py index 1b82c77662d..bcd52facd13 100644 --- a/addons/hr_holidays/models/hr_leave.py +++ b/addons/hr_holidays/models/hr_leave.py @@ -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'): diff --git a/addons/hr_holidays/models/hr_leave_allocation.py b/addons/hr_holidays/models/hr_leave_allocation.py index f92c72b15af..c4896756a01 100644 --- a/addons/hr_holidays/models/hr_leave_allocation.py +++ b/addons/hr_holidays/models/hr_leave_allocation.py @@ -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): diff --git a/addons/hr_holidays/report/hr_leave_report_calendar.py b/addons/hr_holidays/report/hr_leave_report_calendar.py index 0a5b45db9c6..1dd3cd1288a 100644 --- a/addons/hr_holidays/report/hr_leave_report_calendar.py +++ b/addons/hr_holidays/report/hr_leave_report_calendar.py @@ -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 diff --git a/addons/hr_holidays/report/hr_leave_report_calendar.xml b/addons/hr_holidays/report/hr_leave_report_calendar.xml index c7f8a78e477..a62f10faa1e 100644 --- a/addons/hr_holidays/report/hr_leave_report_calendar.xml +++ b/addons/hr_holidays/report/hr_leave_report_calendar.xml @@ -19,6 +19,7 @@ + diff --git a/addons/hr_holidays/static/src/js/time_off_calendar.js b/addons/hr_holidays/static/src/js/time_off_calendar.js index ef9f262d861..3f863de98bf 100644 --- a/addons/hr_holidays/static/src/js/time_off_calendar.js +++ b/addons/hr_holidays/static/src/js/time_off_calendar.js @@ -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); + } }); }, }); diff --git a/addons/hr_holidays/static/src/scss/time_off.scss b/addons/hr_holidays/static/src/scss/time_off.scss index f37b89caf03..ffd80c80722 100644 --- a/addons/hr_holidays/static/src/scss/time_off.scss +++ b/addons/hr_holidays/static/src/scss/time_off.scss @@ -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) { diff --git a/addons/hr_holidays/static/src/xml/time_off_calendar.xml b/addons/hr_holidays/static/src/xml/time_off_calendar.xml index b041222d7fc..97397fc8d5b 100644 --- a/addons/hr_holidays/static/src/xml/time_off_calendar.xml +++ b/addons/hr_holidays/static/src/xml/time_off_calendar.xml @@ -75,4 +75,18 @@ + + +
+
+
+
+

+ + +

+
+
+
+
diff --git a/addons/hr_holidays/views/hr_leave_views.xml b/addons/hr_holidays/views/hr_leave_views.xml index be46d191e47..1ee485953d5 100644 --- a/addons/hr_holidays/views/hr_leave_views.xml +++ b/addons/hr_holidays/views/hr_leave_views.xml @@ -353,10 +353,11 @@ hr.leave.view.dashboard hr.leave - + + @@ -432,10 +433,11 @@ hr.leave.view.calendar hr.leave - + + @@ -605,7 +607,7 @@ My Time Off Requests ir.actions.act_window hr.leave - tree,form,calendar,kanban,activity + tree,form,kanban,activity {} [('user_id', '=', uid)]