diff --git a/hr_leave_dashboard/README.rst b/hr_leave_dashboard/README.rst new file mode 100644 index 000000000..9d8454386 --- /dev/null +++ b/hr_leave_dashboard/README.rst @@ -0,0 +1,49 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Hr Leave Dashboard +================== +This module helps you to brings a multipurpose graphical dashboard for Time Off module and making the relationship management better and easier. + +Configuration +============= +* No Additional configuration is needed. + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +General Public License, Version 3 (AGPL v3). +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Credits +------- +* Developer: + (V16) Rahul Rajeev, + (V17) Jumana Haseen, +Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/hr_leave_dashboard/__init__.py b/hr_leave_dashboard/__init__.py new file mode 100644 index 000000000..0e9656cce --- /dev/null +++ b/hr_leave_dashboard/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Jumana Haseen (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from . import models +from . import report diff --git a/hr_leave_dashboard/__manifest__.py b/hr_leave_dashboard/__manifest__.py new file mode 100644 index 000000000..fb43901e9 --- /dev/null +++ b/hr_leave_dashboard/__manifest__.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Jumana Haseen (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +{ + 'name': "Hr Leave Dashboard", + 'version': '17.0.1.0.0', + 'category': 'Human Resources', + 'summary': """Advanced Leave Dashboard helps to view your and your + subordinate's details""", + 'description': """Advanced Leave Dashboard brings a multipurpose graphical + dashboard for Time Off module and making the relationship management better + and easier""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['base', 'hr_holidays', 'hr_org_chart'], + 'data': [ + 'report/hr_leave_reports.xml', + 'report/hr_leave_report_templates.xml', + ], + 'assets': { + 'web.assets_backend': [ + 'hr_leave_dashboard/static/src/js/calendar_model.js', + 'hr_leave_dashboard/static/src/js/calendar_year_renderer.js', + 'hr_leave_dashboard/static/src/js/hooks.js', + 'hr_leave_dashboard/static/src/js/emp_org_chart.js', + 'hr_leave_dashboard/static/src/js/time_off_emp_card.js', + 'hr_leave_dashboard/static/src/js/time_off_emp_dashboard.js', + 'hr_leave_dashboard/static/src/xml/approval_status_card_templates.xml', + 'hr_leave_dashboard/static/src/xml/time_off_emp_dashboard_templates.xml', + 'hr_leave_dashboard/static/src/xml/emp_org_chart_templates.xml', + 'hr_leave_dashboard/static/src/xml/emp_department_card_templates.xml', + 'hr_leave_dashboard/static/src/xml/time_off_emp_card_templates.xml', + 'hr_leave_dashboard/static/src/css/hr_leave_dashboard.css', + 'hr_org_chart/static/src/fields/hr_org_chart.scss', + 'hr_leave_dashboard/static/src/scss/time_off_dashboard.scss', + 'hr_holidays/static/src/dashboard/time_off_card.scss', + 'hr_leave_dashboard/static/src/scss/calendar_renderer.scss' + ], + }, + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/hr_leave_dashboard/doc/RELEASE_NOTES.md b/hr_leave_dashboard/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..8e5b923ff --- /dev/null +++ b/hr_leave_dashboard/doc/RELEASE_NOTES.md @@ -0,0 +1,7 @@ +## Module + +#### 05.04.2024 +#### Version 17.0.1.0.0 +#### ADD + +- Initial Commit Hr Leave Dashboard diff --git a/hr_leave_dashboard/models/__init__.py b/hr_leave_dashboard/models/__init__.py new file mode 100644 index 000000000..af25a2d2a --- /dev/null +++ b/hr_leave_dashboard/models/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Jumana Haseen (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from . import hr_employee +from . import hr_leave diff --git a/hr_leave_dashboard/models/hr_employee.py b/hr_leave_dashboard/models/hr_employee.py new file mode 100644 index 000000000..869c8b0a9 --- /dev/null +++ b/hr_leave_dashboard/models/hr_employee.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Jumana Haseen (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import models + + +class HrEmployee(models.Model): + """Inherit the model hr.employee to add the functionality for retrieving + public holiday information""" + _inherit = 'hr.employee' + + def get_public_holidays(self, start_date, end_date): + """The function get_public_holidays takes in a start date and end + date as arguments and returns a dictionary with all the public + holidays within that range. It does this by calling the + _get_public_holidays method and then iterating through the results to + add each holiday to the dictionary.""" + all_days = {} + user = self or self.env.user.employee_id + public_holidays = user._get_public_holidays(start_date, end_date) + for holiday in public_holidays: + num_days = (holiday.date_to - holiday.date_from).days + for day in range(num_days + 1): + all_days[str(holiday.date_from.date())] = day + return all_days + + def _get_public_holidays(self, start_date, end_date): + """The _get_public_holidays function searches for public holidays + within a given date range, for all companies associated with the + current environment's user. It returns a recordset of + resource.calendar.leaves that match the search criteria.""" + public_holidays = self.env['resource.calendar.leaves'].search([ + ('date_from', '<=', end_date), + ('date_to', '>=', start_date), + ('resource_id', '=', False), + ('company_id', 'in', self.env.companies.ids), + ]) + return public_holidays diff --git a/hr_leave_dashboard/models/hr_leave.py b/hr_leave_dashboard/models/hr_leave.py new file mode 100644 index 000000000..adf1da6e6 --- /dev/null +++ b/hr_leave_dashboard/models/hr_leave.py @@ -0,0 +1,172 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Jumana Haseen (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +import pytz +from odoo import api, fields, models + + +class HrLeave(models.Model): + """Inherit the model hr.leave to introduce supplementary functionality + aimed at incorporating specific employee details.""" + _inherit = 'hr.leave' + + def _prepare_employee_data(self, employee): + """Function to prepare employee data for the dashboard""" + return { + 'id': employee.id, + 'name': employee.name, + 'job_id': employee.job_id.name, + 'approval_status_count': self.get_approval_status_count(employee.id) + } + + @api.model + def get_current_employee(self): + """This function fetches current employee details in a dictionary""" + current_employee = self.env.user.employee_ids + return { + 'id': current_employee.id, + 'name': current_employee.name, + 'job_id': current_employee.job_id.id, + 'image_1920': current_employee.image_1920, + 'work_email': current_employee.work_email, + 'work_phone': current_employee.work_phone, + 'resource_calendar_id': current_employee.resource_calendar_id.name, + 'link': '/mail/view?model=%s&res_id=%s' % ( + 'hr.employee.public', current_employee.id,), + 'department_id': current_employee.department_id.name, + 'company': current_employee.company_id.name, + 'job_position': current_employee.job_id.name, + 'parent_id': current_employee.parent_id.ids, + 'child_ids': current_employee.child_ids.ids, + 'child_all_count': current_employee.child_all_count, + 'manager': self._prepare_employee_data( + current_employee.parent_id) if ( + current_employee.parent_id) else {}, + 'manager_all_count': len(current_employee.parent_id.ids), + 'children': [self._prepare_employee_data(child) for child in + current_employee.child_ids if + child != current_employee], + } + + @api.model + def get_absentees(self): + """The function retrieves a list of employees who are absent on the + current date by querying the hr_leave table and comparing the + date_from and date_to fields of validated leave requests. It returns + a list of dictionaries containing the employee's name, employee_id, + date_from, and date_to""" + current_employee = self.env.user.employee_ids + children = [self._prepare_employee_data(child) for child in + current_employee.child_ids if + child != current_employee] + child_list = [child.get('id') for child in children] + if len(child_list) > 1: + query = "SELECT employee_id,name,date_from,date_to FROM hr_leave " \ + "INNER JOIN hr_employee ON hr_leave.employee_id = " \ + "hr_employee.id WHERE state = 'validate' AND " \ + "employee_id in %s" % str(tuple(child_list)) + self._cr.execute(query) + elif len(child_list) == 1: + query = "SELECT employee_id,name,date_from,date_to FROM hr_leave " \ + "INNER JOIN hr_employee ON hr_leave.employee_id = " \ + "hr_employee.id WHERE state = 'validate' AND " \ + "employee_id = %s" % child_list[0] + self._cr.execute(query) + leave = self._cr.dictfetchall() + absentees = [ + leave[leave_date] for leave_date in range(len(leave)) + if leave[leave_date].get('date_from') <= fields.datetime.now() <= leave[ + leave_date].get('date_to') + ] + return absentees + + @api.model + def get_current_shift(self): + """ This function fetches current employee's current shift""" + current_employee = self.env.user.employee_ids + employee_tz = current_employee.tz or self.env.context.get('tz') + employee_pytz = pytz.timezone(employee_tz) if employee_tz else pytz.utc + employee_datetime = fields.datetime.now().astimezone(employee_pytz) + hour = employee_datetime.strftime("%H") + minute = employee_datetime.strftime("%M") + day = employee_datetime.strftime("%A") + time = hour + '.' + minute + day_num = '0' if day == 'Monday' else '1' if day == 'Tuesday' \ + else '2' if day == 'Wednesday' else '3' if day == 'Thursday' \ + else '4' if day == 'Friday' else '5' if day == 'Saturday' else '6' + for shift in current_employee.resource_calendar_id.attendance_ids: + if shift.dayofweek == day_num and shift.hour_from <= float( + time) <= shift.hour_to: + return shift.name + return False + + @api.model + def get_upcoming_holidays(self): + """ This function fetches upcoming holidays""" + current_employee = self.env.user.employee_ids + employee_tz = current_employee.tz or self.env.context.get('tz') + employee_pytz = pytz.timezone(employee_tz) if employee_tz else pytz.utc + employee_datetime = fields.datetime.now().astimezone(employee_pytz) + query = "SELECT * FROM public.resource_calendar_leaves WHERE " \ + "resource_id is null" + self._cr.execute(query) + holidays = self._cr.dictfetchall() + upcoming_holidays = [holiday for holiday in holidays if + employee_datetime.date() < holiday.get( + 'date_to').date()] + return upcoming_holidays + + @api.model + def get_approval_status_count(self, current_employee): + """ This function fetches approval status count""" + return { + 'validate_count': self.env['hr.leave'].search_count([ + ('employee_id', '=', current_employee), + ('state', '=', 'validate') + ]), + 'confirm_count': self.env['hr.leave'].search_count([ + ('employee_id', '=', current_employee), + ('state', '=', 'confirm') + ]), + 'refuse_count': self.env['hr.leave'].search_count([ + ('employee_id', '=', current_employee), + ('state', '=', 'refuse') + ]) + } + + @api.model + def get_all_validated_leaves(self): + """ This function fetches all validated leaves""" + leaves = self.env['hr.leave'].search([('state', '=', 'validate')]) + all_validated_leaves = [ + { + 'id': leave.id, + 'employee_id': leave.employee_id.id, + 'employee_name': leave.employee_id.name, + 'request_date_from': leave.request_date_from, + 'request_date_to': leave.request_date_to, + 'leave_type_id': leave.holiday_status_id.id, + 'leave_type': leave.holiday_status_id.name, + 'number_of_days': leave.number_of_days + } + for leave in leaves + ] + return all_validated_leaves diff --git a/hr_leave_dashboard/report/__init__.py b/hr_leave_dashboard/report/__init__.py new file mode 100644 index 000000000..46fb2a8d0 --- /dev/null +++ b/hr_leave_dashboard/report/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Jumana Haseen (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from . import hr_leave_report diff --git a/hr_leave_dashboard/report/hr_leave_report.py b/hr_leave_dashboard/report/hr_leave_report.py new file mode 100644 index 000000000..da8a33fcb --- /dev/null +++ b/hr_leave_dashboard/report/hr_leave_report.py @@ -0,0 +1,108 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Jumana Haseen (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from datetime import timedelta +from odoo import api, fields, models +from odoo.tools import date_utils + + +class HrLeaveReport(models.AbstractModel): + """Model for the dashboard for viewing the employees leave""" + _name = 'report.hr_leave_dashboard.hr_leave_report' + _description = 'HR Leave Report' + + @api.model + def _get_report_values(self, docids, data=None): + """Function for getting the report values""" + today = fields.Date.today() + if data.get('duration') == 'this_month': + start_of_month = date_utils.start_of(today, 'month') + end_of_month = date_utils.end_of(today, 'month') - timedelta(days=1) + option = self.generate_date_range(start_of_month, end_of_month) + elif data.get('duration') == 'this_year': + start_of_year = date_utils.start_of(today, 'year') + end_of_year = date_utils.end_of(today, 'year') - timedelta(days=1) + option = self.generate_date_range(start_of_year, end_of_year) + elif data.get('duration') == 'this_week': + start_of_week = date_utils.start_of(today, 'week') + end_of_week = date_utils.end_of(today, 'week') + option = self.generate_date_range(start_of_week, end_of_week) + else: + option = [str(today)] + + if not self.env.user.employee_ids.child_ids: + query = """SELECT l.id, lt.id as hr_leave_type_id, e.id as + emp_id, e.name as emp_name, e.department_id as emp_department, + e.parent_id as emp_parent_id, request_date_from, request_date_to, + l.number_of_days, lt.name ::jsonb->> 'en_US' as leave_type, + SUM(al.number_of_days) AS allocated_days, SUM(CASE WHEN l.state = + 'validate' THEN l.number_of_days ELSE 0 END) AS taken_days, + SUM(al.number_of_days) - SUM(CASE WHEN l.state = 'validate' THEN + l.number_of_days ELSE 0 END) AS balance_days FROM hr_employee e + inner join hr_leave_allocation al ON al.employee_id = e.id inner + join hr_leave l on l.employee_id = e.id inner join hr_leave_type + lt on l.holiday_status_id = lt.id WHERE l.state = 'validate' AND + e.department_id = '%s' GROUP BY e.id,lt.id,l.id""" % \ + self.env.user.employee_ids.department_id.id + else: + query = """SELECT l.id, lt.id as hr_leave_type_id, e.id as + emp_id, e.name as emp_name, e.department_id as emp_department, + e.parent_id as emp_parent_id, request_date_from, request_date_to, + l.number_of_days, lt.name ::jsonb->> 'en_US' as leave_type, + SUM(al.number_of_days) AS allocated_days, SUM(CASE WHEN l.state = + 'validate' THEN l.number_of_days ELSE 0 END) AS taken_days, + SUM(al.number_of_days) - SUM(CASE WHEN l.state = 'validate' THEN + l.number_of_days ELSE 0 END) AS balance_days FROM hr_employee e + inner join hr_leave_allocation al ON al.employee_id = e.id inner + join hr_leave l on l.employee_id = e.id inner join hr_leave_type + lt on l.holiday_status_id = lt.id WHERE l.state = 'validate' + GROUP BY e.id,lt.id,l.id""" + + self.env.cr.execute(query) + leave_data = self.env.cr.dictfetchall() + filtered_list = [] + filtered_tuple = [] + for leave in leave_data: + leave_list = self.generate_date_range(leave.get('request_date_from'), + leave.get('request_date_to') - timedelta(days=1)) + for date in leave_list: + if date in option: + filtered_list.append(leave) + break + for leave in filtered_list: + if (leave.get('hr_leave_type_id'), leave.get('emp_id')) in filtered_tuple: + filtered_list.remove(leave) + else: + filtered_tuple.append( + (leave.get('hr_leave_type_id'), leave.get('emp_id'))) + return { + 'duration': data.get('duration'), + 'filtered_list': filtered_list, + } + + def generate_date_range(self, start_date, end_date): + """Generate a list of dates within the given range""" + date_list = [] + current_date = start_date + while current_date <= end_date: + date_list.append(current_date.strftime("%Y-%m-%d")) + current_date += timedelta(days=1) + return date_list diff --git a/hr_leave_dashboard/report/hr_leave_report_templates.xml b/hr_leave_dashboard/report/hr_leave_report_templates.xml new file mode 100644 index 000000000..0c85ee162 --- /dev/null +++ b/hr_leave_dashboard/report/hr_leave_report_templates.xml @@ -0,0 +1,89 @@ + + + + + diff --git a/hr_leave_dashboard/report/hr_leave_reports.xml b/hr_leave_dashboard/report/hr_leave_reports.xml new file mode 100644 index 000000000..a7e32cc9f --- /dev/null +++ b/hr_leave_dashboard/report/hr_leave_reports.xml @@ -0,0 +1,11 @@ + + + + + Leave report + hr.leave.report + qweb-pdf + hr_leave_dashboard.hr_leave_report + hr_leave_dashboard.hr_leave_report + + diff --git a/hr_leave_dashboard/static/description/assets/banner.png b/hr_leave_dashboard/static/description/assets/banner.png new file mode 100644 index 000000000..29cc9e171 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/banner.png differ diff --git a/hr_leave_dashboard/static/description/assets/icon.png b/hr_leave_dashboard/static/description/assets/icon.png new file mode 100644 index 000000000..f791741c5 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icon.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/capture (1).png b/hr_leave_dashboard/static/description/assets/icons/capture (1).png new file mode 100644 index 000000000..8824deafc Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/capture (1).png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/check.png b/hr_leave_dashboard/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/check.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/chevron.png b/hr_leave_dashboard/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/chevron.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/cogs.png b/hr_leave_dashboard/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/cogs.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/consultation.png b/hr_leave_dashboard/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/consultation.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/ecom-black.png b/hr_leave_dashboard/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/ecom-black.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/education-black.png b/hr_leave_dashboard/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/education-black.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/hotel-black.png b/hr_leave_dashboard/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/hotel-black.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/img.png b/hr_leave_dashboard/static/description/assets/icons/img.png new file mode 100644 index 000000000..70197f477 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/img.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/license.png b/hr_leave_dashboard/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/license.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/lifebuoy.png b/hr_leave_dashboard/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/lifebuoy.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/manufacturing-black.png b/hr_leave_dashboard/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/manufacturing-black.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/photo-capture.png b/hr_leave_dashboard/static/description/assets/icons/photo-capture.png new file mode 100644 index 000000000..06c111758 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/photo-capture.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/pos-black.png b/hr_leave_dashboard/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/pos-black.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/puzzle.png b/hr_leave_dashboard/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/puzzle.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/restaurant-black.png b/hr_leave_dashboard/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/restaurant-black.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/service-black.png b/hr_leave_dashboard/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/service-black.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/trading-black.png b/hr_leave_dashboard/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/trading-black.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/training.png b/hr_leave_dashboard/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/training.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/update.png b/hr_leave_dashboard/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/update.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/user.png b/hr_leave_dashboard/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/user.png differ diff --git a/hr_leave_dashboard/static/description/assets/icons/wrench.png b/hr_leave_dashboard/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/icons/wrench.png differ diff --git a/hr_leave_dashboard/static/description/assets/misc/Cybrosys R.png b/hr_leave_dashboard/static/description/assets/misc/Cybrosys R.png new file mode 100644 index 000000000..da4058087 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/misc/Cybrosys R.png differ diff --git a/hr_leave_dashboard/static/description/assets/misc/email.svg b/hr_leave_dashboard/static/description/assets/misc/email.svg new file mode 100644 index 000000000..15291cdc3 --- /dev/null +++ b/hr_leave_dashboard/static/description/assets/misc/email.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hr_leave_dashboard/static/description/assets/misc/logo-horizontal (1).png b/hr_leave_dashboard/static/description/assets/misc/logo-horizontal (1).png new file mode 100644 index 000000000..e64152348 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/misc/logo-horizontal (1).png differ diff --git a/hr_leave_dashboard/static/description/assets/misc/phone.svg b/hr_leave_dashboard/static/description/assets/misc/phone.svg new file mode 100644 index 000000000..b7bd7f251 --- /dev/null +++ b/hr_leave_dashboard/static/description/assets/misc/phone.svg @@ -0,0 +1,3 @@ + + + diff --git a/hr_leave_dashboard/static/description/assets/misc/star (1) 2.svg b/hr_leave_dashboard/static/description/assets/misc/star (1) 2.svg new file mode 100644 index 000000000..5ae9f507a --- /dev/null +++ b/hr_leave_dashboard/static/description/assets/misc/star (1) 2.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/hr_leave_dashboard/static/description/assets/misc/support (1) 1.svg b/hr_leave_dashboard/static/description/assets/misc/support (1) 1.svg new file mode 100644 index 000000000..7d37a8f30 --- /dev/null +++ b/hr_leave_dashboard/static/description/assets/misc/support (1) 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/hr_leave_dashboard/static/description/assets/misc/support-email.svg b/hr_leave_dashboard/static/description/assets/misc/support-email.svg new file mode 100644 index 000000000..eb70370d6 --- /dev/null +++ b/hr_leave_dashboard/static/description/assets/misc/support-email.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/hr_leave_dashboard/static/description/assets/misc/tick-mark.svg b/hr_leave_dashboard/static/description/assets/misc/tick-mark.svg new file mode 100644 index 000000000..2dbb40187 --- /dev/null +++ b/hr_leave_dashboard/static/description/assets/misc/tick-mark.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/hr_leave_dashboard/static/description/assets/misc/whatsapp 1.svg b/hr_leave_dashboard/static/description/assets/misc/whatsapp 1.svg new file mode 100644 index 000000000..0bfaf8fc6 --- /dev/null +++ b/hr_leave_dashboard/static/description/assets/misc/whatsapp 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/hr_leave_dashboard/static/description/assets/misc/whatsapp.svg b/hr_leave_dashboard/static/description/assets/misc/whatsapp.svg new file mode 100644 index 000000000..b618aea1d --- /dev/null +++ b/hr_leave_dashboard/static/description/assets/misc/whatsapp.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hr_leave_dashboard/static/description/assets/modules/1.png b/hr_leave_dashboard/static/description/assets/modules/1.png new file mode 100644 index 000000000..000ef5949 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/modules/1.png differ diff --git a/hr_leave_dashboard/static/description/assets/modules/2.png b/hr_leave_dashboard/static/description/assets/modules/2.png new file mode 100644 index 000000000..7c7b63f73 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/modules/2.png differ diff --git a/hr_leave_dashboard/static/description/assets/modules/3.png b/hr_leave_dashboard/static/description/assets/modules/3.png new file mode 100644 index 000000000..deb815b44 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/modules/3.png differ diff --git a/hr_leave_dashboard/static/description/assets/modules/4.png b/hr_leave_dashboard/static/description/assets/modules/4.png new file mode 100644 index 000000000..9dd4ce6fd Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/modules/4.png differ diff --git a/hr_leave_dashboard/static/description/assets/modules/5.png b/hr_leave_dashboard/static/description/assets/modules/5.png new file mode 100644 index 000000000..6cd566cc4 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/modules/5.png differ diff --git a/hr_leave_dashboard/static/description/assets/modules/6.png b/hr_leave_dashboard/static/description/assets/modules/6.png new file mode 100644 index 000000000..f808106b9 Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/modules/6.png differ diff --git a/hr_leave_dashboard/static/description/assets/screenshots/1.png b/hr_leave_dashboard/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..ea127163f Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/screenshots/1.png differ diff --git a/hr_leave_dashboard/static/description/assets/screenshots/2.png b/hr_leave_dashboard/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..fa7a13b8a Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/screenshots/2.png differ diff --git a/hr_leave_dashboard/static/description/assets/screenshots/hero.gif b/hr_leave_dashboard/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..6ed431b8a Binary files /dev/null and b/hr_leave_dashboard/static/description/assets/screenshots/hero.gif differ diff --git a/hr_leave_dashboard/static/description/banner.jpg b/hr_leave_dashboard/static/description/banner.jpg new file mode 100644 index 000000000..29cc9e171 Binary files /dev/null and b/hr_leave_dashboard/static/description/banner.jpg differ diff --git a/hr_leave_dashboard/static/description/icon.png b/hr_leave_dashboard/static/description/icon.png new file mode 100644 index 000000000..f791741c5 Binary files /dev/null and b/hr_leave_dashboard/static/description/icon.png differ diff --git a/hr_leave_dashboard/static/description/index.html b/hr_leave_dashboard/static/description/index.html new file mode 100644 index 000000000..84f413984 --- /dev/null +++ b/hr_leave_dashboard/static/description/index.html @@ -0,0 +1,651 @@ + + + + + + Odoo App 3 Index + + + + + + + + +
+
+
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+
+
+
+
+
+

+ Hr Leave Dashboard

+

+ This Module Helps You to + View Your and Your Subordinate's Details. +

+
+ +
+
+
+
+
+

+ Key Highlights +

+
+
+
+
+
+ +
+
+

+ View your and your subordinate's details and + approval status of your all employees..

+
+
+
+
+
+
+ +
+
+

+ Print hr leave report on basis of today, + this week, this month and this year + in pdf format.

+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+

+ HR Leave Dashboard

+
+
+
+
+
+
+ +
+
+

+ HR Leave PDF Report

+
+
+
+
+
+
+
    +
  • + Available in + Odoo 17.0 Community +
  • +
  • + Hr Leave + Dashboard +
      +
    • This module helps you view your and + your subordinate's details and + approval status of your all employees. + With this module, you can print hr leave + report on basis of today, + this week, this month and this year + in pdf format. +
    • +
    +
  • +
+
+
+
+
+
+
Version + 17.0.1.0.0|Released on:5th April 2024 +
+

+ Initial Commit for Hr Leave Dashboard +

+
+
+
+
+
+
+
+

+ Related Products

+
+
+ +
+
+

+ Our Services

+
+
+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Customization

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Implementation

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Support

+
+
+
+
+
+
+ service-icon +
+
+

Hire + Odoo Developer

+
+
+
+
+ +
+
+ service-icon +
+
+

Odoo + Integration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Migration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Consultancy

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Implementation

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Licensing Consultancy

+
+
+
+
+
+
+

+ Our Industries

+
+
+
+
+
+
+ +

Trading

+

Easily procure and sell your products

+
+
+
+
+ +

POS

+

Easy configuration and convivial experience

+
+
+
+
+ +

+ Education

+

A platform for educational management

+
+
+
+
+ +

+ Manufacturing

+

Plan, track and schedule your operations

+
+
+
+
+ +

E-commerce & + Website

+

Mobile friendly, awe-inspiring product pages

+
+
+
+
+ +

Service + Management

+

Keep track of services and invoice

+
+
+
+
+ +

+ Restaurant

+

Run your bar or restaurant methodically

+
+
+
+
+ +

Hotel + Management

+

An all-inclusive hotel management application

+
+
+
+
+
+
+

+ Support

+
+
+
+
+
+
+
+ +
+ Need + Help? +

Got + questions or need help? Get in touch.

+
odoo@cybrosys.com +
+
+
+
+
+
+
+
+ +
+ WhatsApp +

Say hi to + us on WhatsApp!

+
+91 + 99456767686 +
+
+
+
+
+
+
+
+
+ + + + + + diff --git a/hr_leave_dashboard/static/src/css/hr_leave_dashboard.css b/hr_leave_dashboard/static/src/css/hr_leave_dashboard.css new file mode 100644 index 000000000..ae8811ceb --- /dev/null +++ b/hr_leave_dashboard/static/src/css/hr_leave_dashboard.css @@ -0,0 +1,90 @@ +td.fc-day.fc-widget-content.fc-public-holiday{ + background-color:red !important; +} +td.fc-day.fc-widget-content.fc-sat{ + background-color:red !important; +} +td.fc-day.fc-widget-content.fc-sun{ + background-color:red !important; +} +.holidaay{ +display :none !important; +} +.o_timeoff_duration{ + margin-top:12px !important; +} +.employee_details{ + font-size:12px !important; + margin-top: 12px; + margin-bottom: 12px; +} +.o_timeoff_card:not(:last-child) { + font-size: 12px !important; + padding: 12px !important; + position:relative; +} +.o_timeoff_card .o_timeoff_duration{ + margin-bottom:12px !important; +} +.o_treeEntry:before, .o_treeEntry:after{ + background: #7a539e !important; +} +.duration{ + width: 190px; + float: left; + margin: 1px 2px 0px 10px; + height: 29px; + padding: 5px; + margin-bottom: 21px; +} +.time_off_dashboard_table tr th{ + background-color: #eaeef3 !important; + font-size: 11px; +} +.employee_image{ + border-radius: 50%; + width: 50px; + height: 50px; + overflow: hidden; + position: relative; +} +.employee_name{ + font-size: 16px !important; + width: 165px; + /* position: absolute; */ + right:62px; + top:24px; +} +.employee_box{ + display:flex; + justify-content:center; + align-items:center; +} +.divider-box{ +float: left; + margin-bottom: 12px; + text-align: center; + display: flex; + align-items: center; + justify-content: center; +} +.box-content{ +width: 100%; + margin-right: 2px; + padding: 10px; + display: flex; + align-items: center; + justify-content: center; + height: 80px; + margin-top: 0px; + border: 1px solid #cebce1; + background-color: #eaedf3; + color: #573674; +} +.divide-leave{ +padding:10px; +border: 1px solid #cebce1; +background-color: #eaedf3; +color: #573674; +margin-top:10px; +} diff --git a/hr_leave_dashboard/static/src/js/calendar_model.js b/hr_leave_dashboard/static/src/js/calendar_model.js new file mode 100644 index 000000000..66e613c67 --- /dev/null +++ b/hr_leave_dashboard/static/src/js/calendar_model.js @@ -0,0 +1,32 @@ +/** @odoo-module */ +import { TimeOffCalendarModel } from '@hr_holidays/views/calendar/calendar_model'; +import { serializeDate } from "@web/core/l10n/dates"; +import { patch } from "@web/core/utils/patch"; +//The patch function to modify the TimeOffCalendarModel prototype by adding or +//modifying several methods and properties: setup, updateData, +//fetchPublicHolidays, and a getter for publicHolidays. +patch(TimeOffCalendarModel.prototype,{ + setup(params, services) { + super.setup(params, services); + this.data.publicHolidays = {}; + if (this.env.isSmall) { + this.meta.scale = 'month'; + } + }, + async updateData(data) { + await super.updateData(data); + data.publicHolidays = await this.fetchPublicHolidays(data); + }, + // Fetches public holidays in a year + async fetchPublicHolidays(data) { + return this.orm.call("hr.employee", "get_public_holidays", [ + this.employeeId, + serializeDate(data.range.start, "datetime"), + serializeDate(data.range.end, "datetime"), + ]); + }, + get publicHolidays() { + return this.data.publicHolidays; + } + +}); diff --git a/hr_leave_dashboard/static/src/js/calendar_year_renderer.js b/hr_leave_dashboard/static/src/js/calendar_year_renderer.js new file mode 100644 index 000000000..56add69d3 --- /dev/null +++ b/hr_leave_dashboard/static/src/js/calendar_year_renderer.js @@ -0,0 +1,15 @@ +/** @odoo-module */ +import { patch } from "@web/core/utils/patch"; +import { TimeOffCalendarYearRenderer } from "@hr_holidays/views/calendar/year/calendar_year_renderer"; +import { usePublicHolidays } from "@hr_leave_dashboard/js/hooks"; + +patch(TimeOffCalendarYearRenderer.prototype, { + setup() { + super.setup(); + this.publicHolidays = usePublicHolidays(this.props); + }, + onDayRender(info) { + super.onDayRender(info); + this.publicHolidays(info); + } +}); diff --git a/hr_leave_dashboard/static/src/js/emp_org_chart.js b/hr_leave_dashboard/static/src/js/emp_org_chart.js new file mode 100644 index 000000000..38bae9892 --- /dev/null +++ b/hr_leave_dashboard/static/src/js/emp_org_chart.js @@ -0,0 +1,111 @@ +/** @odoo-module */ +import { useService } from "@web/core/utils/hooks"; +import { usePopover } from "@web/core/popover/popover_hook"; +import { onEmployeeSubRedirect } from "@hr_org_chart/fields/hooks" +const { Component, onWillStart, onWillRender, useState } = owl; +import { session } from "@web/session"; +import { registry } from "@web/core/registry"; + +//Class TimeOffEmpOrgChartPopover that extends +//the Component class. It is a custom component used for handling +//popovers in an employee organization chart. +class TimeOffEmpOrgChartPopover extends Component { + setup() { + super.setup(); + this.rpc = useService('rpc'); + this.orm = useService('orm'); + this.user = useService("user"); + this.actionService = useService("action"); + } + /** + * Redirect to the employee form view. + * + * @private + * @param {MouseEvent} event + * @returns {Promise} action loaded + */ + async _onEmployeeRedirect(employeeId) { + const action = await this.orm.call('hr.employee', 'get_formview_action', [employeeId]); + this.actionService.doAction(action); + } +} +TimeOffEmpOrgChartPopover.template = 'hr_leave_dashboard.hr_orgchart_emp_popover'; +//Exports a class TimeOffEmpOrgChart that extends the Component class. +//It is a custom component used for displaying an employee organization chart. +export class TimeOffEmpOrgChart extends Component { + async setup() { + super.setup(); + this.rpc = useService('rpc'); + this.orm = useService('orm'); + this.popover = usePopover(TimeOffEmpOrgChartPopover); + this.actionService = useService("action"); + this.jsonStringify = JSON.stringify; + this.state = useState({'employee_id': null}); + this._onEmployeeSubRedirect = onEmployeeSubRedirect(); + onWillStart(this.handleComponentUpdate.bind(this)); + onWillRender(this.handleComponentUpdate.bind(this)); + } + /** + * Called on start and on render + */ + async handleComponentUpdate() { + this.employee = this.props.id; + // The widget is either displayed in the context of a hr.employee form or a res.users form + this.state.employee_id = this.props; + const forceReload = this.lastRecord !== this.props.record; + this.lastRecord = this.props.record; + await this.fetchEmployeeData(this.state.employee_id, forceReload); + } + async fetchEmployeeData(employeeId, force = false) { + employeeId = this.props.id + if (!employeeId) { + this.managers = []; + this.children = []; + if (this.view_employee_id) { + this.render(true); + } + this.view_employee_id = null; + } else if (employeeId !== this.view_employee_id || force) { + this.view_employee_id = employeeId; + var orgData = await this.rpc( + '/hr/get_org_chart', + { + employee_id: employeeId, + context: session.user_context, + } + ); + if (Object.keys(orgData).length === 0) { + orgData = { + managers: [], + children: [], + } + } + this.managers = orgData.managers; + + this.children = orgData.children; + this.managers_more = orgData.managers_more; + this.self = orgData.self; + this.render(true); + } + } + + _onOpenPopover(event, employee) { + this.popover.open(event.currentTarget, { employee }); + } + async _onEmployeeRedirect(employeeId) { + const action = await this.orm.call('hr.employee', 'get_formview_action', [employeeId]); + this.actionService.doAction(action); + } + + async _onEmployeeMoreManager(managerId) { + await this.fetchEmployeeData(managerId); + this.state.employee_id = managerId; + } +} +TimeOffEmpOrgChart.template = 'hr_leave_dashboard.hr_org_chart'; + +TimeOffEmpOrgChart.components = { + Popover: TimeOffEmpOrgChartPopover, +}; + + diff --git a/hr_leave_dashboard/static/src/js/hooks.js b/hr_leave_dashboard/static/src/js/hooks.js new file mode 100644 index 000000000..467497c04 --- /dev/null +++ b/hr_leave_dashboard/static/src/js/hooks.js @@ -0,0 +1,23 @@ +/** @odoo-module */ +//Exports a custom hook usePublicHolidays that takes in props as a parameter. +//This hook is likely intended to be used in a calendar component to mark public holidays. +/** @odoo-module **/ +import { useService } from "@web/core/utils/hooks"; + +/** + * Redirect to the sub employee kanban view. + * + * @private + * @param {MouseEvent} event + * @returns {Promise} action loaded + * + */ +export function usePublicHolidays(props) { + return (info) => { + const date = luxon.DateTime.fromJSDate(info.date).toISODate(); + const publicHolidays = props.model.publicHolidays[date]; + if (publicHolidays) { + info.el.classList.add('fc-public-holiday'); + } + } +} diff --git a/hr_leave_dashboard/static/src/js/time_off_emp_card.js b/hr_leave_dashboard/static/src/js/time_off_emp_card.js new file mode 100644 index 000000000..8ac32536e --- /dev/null +++ b/hr_leave_dashboard/static/src/js/time_off_emp_card.js @@ -0,0 +1,61 @@ +/* @odoo-module */ +import { useService } from "@web/core/utils/hooks"; +import { Component, onWillStart } from "@odoo/owl"; +export class TimeOffEmpCard extends Component {} +TimeOffEmpCard.template = 'hr_leave_dashboard.TimeOffEmpCard'; +TimeOffEmpCard.props = ['name', 'id', 'department_id', 'job_position', +'children', 'image_1920', 'work_email', 'work_phone', 'company', 'resource_calendar_id']; +//Exports a class TimeOffEmpOrgChart that extends the Component class. +//It is a custom component used for managing an employee organization +//chart in the context of time off and holidays. +export class TimeOffEmpOrgChart extends Component { + setup() { + super.setup(); + this.props; + this.userService = useService('user'); + onWillStart(async () => { + this.manager = await this.userService.hasGroup("hr_holidays.group_hr_holidays_manager"); + }); + + } +} +TimeOffEmpOrgChart.template = 'hr_leave_dashboard.hr_org_chart'; +TimeOffEmpOrgChart.props = ['name', 'id', 'department_id', 'job_position', 'children']; +export class EmpDepartmentCard extends Component {} +EmpDepartmentCard.template = 'hr_leave_dashboard.EmpDepartmentCard'; +EmpDepartmentCard.props = ['name', 'id', 'department_id', 'child_all_count', +'children', 'absentees', 'current_shift', 'upcoming_holidays']; +//Exports a class ApprovalStatusCard that extends the Component class. +//It is a custom component used for managing the approval status of +//a card, possibly related to HR leave requests. +export class ApprovalStatusCard extends Component { + setup() { + super.setup(); + this.userService = useService('user'); + this.props; + this.rpc = useService('rpc'); + this.actionService = useService("action"); + + onWillStart(async () => { + await this.userService.hasGroup('hr_holidays.group_hr_holidays_manager').then(hasGroup => { + this.manager = hasGroup; + }) + }); +} + async printPdfReport() { + const duration = $(this.__owl__.bdom.el.querySelectorAll("#duration")).val(); + return this.actionService.doAction({ + type: "ir.actions.report", + report_type: "qweb-pdf", + report_name: "hr_leave_dashboard.hr_leave_report", + report_file: "hr_leave_dashboard.hr_leave_report", + data: { + 'duration': duration, + 'all_validated_leaves': this.props.all_validated_leaves, + } + }); + } + } +ApprovalStatusCard.template = 'hr_leave_dashboard.ApprovalStatusCard'; +ApprovalStatusCard.props = ['id','name','approval_status_count','child_ids', +'children', 'all_validated_leaves']; diff --git a/hr_leave_dashboard/static/src/js/time_off_emp_dashboard.js b/hr_leave_dashboard/static/src/js/time_off_emp_dashboard.js new file mode 100644 index 000000000..7bddc4198 --- /dev/null +++ b/hr_leave_dashboard/static/src/js/time_off_emp_dashboard.js @@ -0,0 +1,107 @@ +/** @odoo-module */ +import { patch } from "@web/core/utils/patch"; +import { TimeOffDashboard } from '@hr_holidays/dashboard/time_off_dashboard'; +import { TimeOffCard } from '@hr_holidays/dashboard/time_off_card'; +import { TimeOffEmpCard } from './time_off_emp_card'; +import { TimeOffEmpOrgChart } from './emp_org_chart'; +import { EmpDepartmentCard } from './time_off_emp_card'; +import { ApprovalStatusCard } from './time_off_emp_card'; +import { Component, onWillStart, useState } from "@odoo/owl"; +import { useService } from "@web/core/utils/hooks"; + +//The code is a patch that modifies the loadDashboardData method of the TimeOffDashboard class. +patch(TimeOffDashboard.prototype,{ + + setup() { + super.setup(); + this.userService = useService('user'); + this.currentEmployee = useState({ + data: {} + + }) + this.currentAbsentees = useState({ + data: {} + + }) + this.currentShift = useState({ + data: {} + + }) + this.upcoming_holidays = useState({ + data: {} + + }) + + onWillStart(async() => { + await this.userService.hasGroup('hr_holidays.group_hr_holidays_manager').then(hasGroup => { + this.manager = hasGroup; + }) + this.currentEmployee.data = await this.orm.call( + 'hr.leave', + 'get_current_employee', + [], + { + context: { + employee_id: this.props.employeeId + } + } + ); + this.currentAbsentees.data = await this.orm.call( + 'hr.leave', + 'get_absentees', + [], + { + context: { + employee_id: this.props.employeeId + } + } + + ); + this.currentShift.data = await this.orm.call( + 'hr.leave', + 'get_current_shift', + [], + { + context: { + employee_id: this.props.employeeId + } + } + ); + this.upcoming_holidays.data = await this.orm.call( + 'hr.leave', + 'get_upcoming_holidays', + [], + { + context: { + employee_id: this.props.employeeId + } + } + ); + this.approval_status_count = await this.orm.call( + 'hr.leave', + 'get_approval_status_count', + [this.currentEmployee.data.id], + { + context: { + employee_id: this.props.employeeId + } + } + ); + this.all_validated_leaves = await this.orm.call( + 'hr.leave', + 'get_all_validated_leaves', + [], + { + context: { + employee_id: this.props.employeeId + } + } + ); + if (this.props.employeeId == null) { + this.props.employeeId = this.currentEmployee.data.id; + } + + }) + }, +}); +TimeOffDashboard.components = { ...TimeOffDashboard.components, TimeOffCard, TimeOffEmpCard ,TimeOffEmpOrgChart, EmpDepartmentCard, ApprovalStatusCard}; diff --git a/hr_leave_dashboard/static/src/scss/calendar_renderer.scss b/hr_leave_dashboard/static/src/scss/calendar_renderer.scss new file mode 100644 index 000000000..50a78e3da --- /dev/null +++ b/hr_leave_dashboard/static/src/scss/calendar_renderer.scss @@ -0,0 +1,16 @@ +.o_timeoff_calendar { + .o_calendar_renderer { + height: unset; + .o_calendar_widget { + @for $size from 1 through length($o-colors) { + .hr_public_holiday_#{$size - 1}:not(.fc-disabled-day) { + background: nth($o-colors, $size) !important; + opacity: 0.4; + } + } + } + .fc-bgevent { + border-radius: 25px; + } + } +} diff --git a/hr_leave_dashboard/static/src/scss/time_off_dashboard.scss b/hr_leave_dashboard/static/src/scss/time_off_dashboard.scss new file mode 100644 index 000000000..070f58ccb --- /dev/null +++ b/hr_leave_dashboard/static/src/scss/time_off_dashboard.scss @@ -0,0 +1,11 @@ +.o_timeoff_dashboard { + display: flex; + justify-content: space-between; + height: auto; + box-shadow: inset 0 -1px 0 $border-color; + position: sticky; + top: 0; + z-index: 100; + background-color: $o-webclient-background-color; +} + diff --git a/hr_leave_dashboard/static/src/xml/approval_status_card_templates.xml b/hr_leave_dashboard/static/src/xml/approval_status_card_templates.xml new file mode 100644 index 000000000..bf7545424 --- /dev/null +++ b/hr_leave_dashboard/static/src/xml/approval_status_card_templates.xml @@ -0,0 +1,70 @@ + + + + + +
+ + + +
+ + + +
+ Approved +
+ + + +
+ To Approve +
+ + + +
+ Refused +
+
+
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + +
NameApprovedTo ApproveRefused
+
+
+
+
diff --git a/hr_leave_dashboard/static/src/xml/emp_department_card_templates.xml b/hr_leave_dashboard/static/src/xml/emp_department_card_templates.xml new file mode 100644 index 000000000..027d4d27c --- /dev/null +++ b/hr_leave_dashboard/static/src/xml/emp_department_card_templates.xml @@ -0,0 +1,45 @@ + + + + + +
+ + + + + + + + + + + +
+
+ Current Shift: +
+
+
+
Upcoming Holidays
+ +
+ +
+
+ () +
+
+
+
+
On Leave
+ +
+ +
+
+
+
+
diff --git a/hr_leave_dashboard/static/src/xml/emp_org_chart_templates.xml b/hr_leave_dashboard/static/src/xml/emp_org_chart_templates.xml new file mode 100644 index 000000000..ccda6b55d --- /dev/null +++ b/hr_leave_dashboard/static/src/xml/emp_org_chart_templates.xml @@ -0,0 +1,168 @@ + + + + + + +
+
+ + + +
+
+ +
+ + + +
+
+ +
+ + +
+
+
+ + + + +
+ + + + + + + +
+ + + + + + + +
+ + + + + + + + + + +
+
+ See All +
+
+
+
+
+ + + + diff --git a/hr_leave_dashboard/static/src/xml/time_off_emp_card_templates.xml b/hr_leave_dashboard/static/src/xml/time_off_emp_card_templates.xml new file mode 100644 index 000000000..779b62b4a --- /dev/null +++ b/hr_leave_dashboard/static/src/xml/time_off_emp_card_templates.xml @@ -0,0 +1,77 @@ + + + + + +
+ + + + + + + + + + + +
+
+ + + +
+ + + +
+
+
+
+ Job Position: + +
+
+
+
+ Working Hours: + +
+
+
+
+ EMAIL: +
+
+
+
+ PHONE: +
+
+
+
+ Department: +
+
+
+
+ Company: +
+
+
+
+
diff --git a/hr_leave_dashboard/static/src/xml/time_off_emp_dashboard_templates.xml b/hr_leave_dashboard/static/src/xml/time_off_emp_dashboard_templates.xml new file mode 100644 index 000000000..b2418bf02 --- /dev/null +++ b/hr_leave_dashboard/static/src/xml/time_off_emp_dashboard_templates.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + +