diff --git a/hr_attendance_xlsx_report/README.rst b/hr_attendance_xlsx_report/README.rst new file mode 100644 index 000000000..ef0d7810a --- /dev/null +++ b/hr_attendance_xlsx_report/README.rst @@ -0,0 +1,37 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Employee Attendance Xlsx Report +======================= +This module helps to manage the XLSX report of the attendance of employees. + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +Developer: LAJINA K V @cybrosys, 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: ``__ \ No newline at end of file diff --git a/hr_attendance_xlsx_report/__init__.py b/hr_attendance_xlsx_report/__init__.py new file mode 100644 index 000000000..88c880622 --- /dev/null +++ b/hr_attendance_xlsx_report/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: LAJINA KV (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 controller +from . import wizard diff --git a/hr_attendance_xlsx_report/__manifest__.py b/hr_attendance_xlsx_report/__manifest__.py new file mode 100644 index 000000000..aa14e599e --- /dev/null +++ b/hr_attendance_xlsx_report/__manifest__.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: LAJINA KV (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': "Employee Attendance Xlsx Report", + 'version': '15.0.1.0.0', + 'category': 'Human Resources/Attendances', + 'summary': """Manage the attendance report of employees in XLSX""", + 'description': """ + This module helps to generate the attendance report of employees in the + XLSX format + """, + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['hr_attendance'], + 'data': [ + 'security/ir.model.access.csv', + 'wizard/employee_attendance_report_views.xml' + ], + 'assets': { + 'web.assets_backend': [ + 'hr_attendance_xlsx_report/static/src/js/action_manager.js', + ] + }, + 'images': ['static/description/banner.png'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False +} diff --git a/hr_attendance_xlsx_report/controller/__init__.py b/hr_attendance_xlsx_report/controller/__init__.py new file mode 100644 index 000000000..e7fb7b11e --- /dev/null +++ b/hr_attendance_xlsx_report/controller/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: LAJINA KV (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_attendance_xlsx_report diff --git a/hr_attendance_xlsx_report/controller/hr_attendance_xlsx_report.py b/hr_attendance_xlsx_report/controller/hr_attendance_xlsx_report.py new file mode 100644 index 000000000..b42e9fb57 --- /dev/null +++ b/hr_attendance_xlsx_report/controller/hr_attendance_xlsx_report.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: LAJINA KV (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 json + +from odoo import http +from odoo.http import content_disposition, request, serialize_exception +from odoo.tools import html_escape + + +class XLSXReportController(http.Controller): + """ XLSX Report controller """ + @http.route('/xlsx_reports', type='http', auth='user', methods=['POST'], + csrf=False) + def get_report_xlsx(self, model, options, output_format, report_name): + """ XLSX report """ + report_obj = request.env[model].with_user(request.session.uid) + options = json.loads(options) + token = 'dummy-because-api-expects-one' + try: + if output_format == 'xlsx': + response = request.make_response( + None, + headers=[ + ('Content-Type', 'application/vnd.ms-excel'), + ('Content-Disposition', content_disposition( + report_name + '.xlsx')) + ] + ) + report_obj.get_xlsx_report(options, response) + response.set_cookie('fileToken', token) + return response + except Exception as e: + se = serialize_exception(e) + error = { + 'code': 200, + 'message': 'Odoo Server Error', + 'data': se + } + return request.make_response(html_escape(json.dumps(error))) diff --git a/hr_attendance_xlsx_report/doc/RELEASE_NOTES.md b/hr_attendance_xlsx_report/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..10dba1046 --- /dev/null +++ b/hr_attendance_xlsx_report/doc/RELEASE_NOTES.md @@ -0,0 +1,7 @@ +## Module + +#### 11.04.2023 +#### Version 15.0.1.0.0 +#### ADD + +- Initial commit for Employee Attendance Xlsx Report \ No newline at end of file diff --git a/hr_attendance_xlsx_report/security/ir.model.access.csv b/hr_attendance_xlsx_report/security/ir.model.access.csv new file mode 100644 index 000000000..0ddc2363e --- /dev/null +++ b/hr_attendance_xlsx_report/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_employee_attendance_report_user,access.employee.attendance.report.user,model_employee_attendance_report,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/check.png b/hr_attendance_xlsx_report/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/check.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/chevron.png b/hr_attendance_xlsx_report/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/chevron.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/cogs.png b/hr_attendance_xlsx_report/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/cogs.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/consultation.png b/hr_attendance_xlsx_report/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/consultation.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/ecom-black.png b/hr_attendance_xlsx_report/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/ecom-black.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/education-black.png b/hr_attendance_xlsx_report/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/education-black.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/hotel-black.png b/hr_attendance_xlsx_report/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/hotel-black.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/license.png b/hr_attendance_xlsx_report/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/license.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/lifebuoy.png b/hr_attendance_xlsx_report/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/lifebuoy.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/logo.png b/hr_attendance_xlsx_report/static/description/assets/icons/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/logo.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/manufacturing-black.png b/hr_attendance_xlsx_report/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/manufacturing-black.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/pos-black.png b/hr_attendance_xlsx_report/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/pos-black.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/puzzle.png b/hr_attendance_xlsx_report/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/puzzle.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/restaurant-black.png b/hr_attendance_xlsx_report/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/restaurant-black.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/service-black.png b/hr_attendance_xlsx_report/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/service-black.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/trading-black.png b/hr_attendance_xlsx_report/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/trading-black.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/training.png b/hr_attendance_xlsx_report/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/training.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/update.png b/hr_attendance_xlsx_report/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/update.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/user.png b/hr_attendance_xlsx_report/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/user.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/icons/wrench.png b/hr_attendance_xlsx_report/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/icons/wrench.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/modules/budget_image.png b/hr_attendance_xlsx_report/static/description/assets/modules/budget_image.png new file mode 100644 index 000000000..b50130c7d Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/modules/budget_image.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/modules/credit_image.png b/hr_attendance_xlsx_report/static/description/assets/modules/credit_image.png new file mode 100644 index 000000000..3ad04ecfd Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/modules/credit_image.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/modules/employee_image.png b/hr_attendance_xlsx_report/static/description/assets/modules/employee_image.png new file mode 100644 index 000000000..30ad58232 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/modules/employee_image.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/modules/export_image.png b/hr_attendance_xlsx_report/static/description/assets/modules/export_image.png new file mode 100644 index 000000000..492980ad0 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/modules/export_image.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/modules/gantt_image.png b/hr_attendance_xlsx_report/static/description/assets/modules/gantt_image.png new file mode 100644 index 000000000..1ae7cfe3b Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/modules/gantt_image.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/modules/quotation_image.png b/hr_attendance_xlsx_report/static/description/assets/modules/quotation_image.png new file mode 100644 index 000000000..499b1a72f Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/modules/quotation_image.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/screenshots/hero.gif b/hr_attendance_xlsx_report/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..280f9b745 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/screenshots/hero.gif differ diff --git a/hr_attendance_xlsx_report/static/description/assets/screenshots/xlsx1.png b/hr_attendance_xlsx_report/static/description/assets/screenshots/xlsx1.png new file mode 100644 index 000000000..df59503ed Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/screenshots/xlsx1.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/screenshots/xlsx2.png b/hr_attendance_xlsx_report/static/description/assets/screenshots/xlsx2.png new file mode 100644 index 000000000..c84d216d8 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/screenshots/xlsx2.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/screenshots/xlsx3.png b/hr_attendance_xlsx_report/static/description/assets/screenshots/xlsx3.png new file mode 100644 index 000000000..426a26679 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/screenshots/xlsx3.png differ diff --git a/hr_attendance_xlsx_report/static/description/assets/screenshots/xlsx4.png b/hr_attendance_xlsx_report/static/description/assets/screenshots/xlsx4.png new file mode 100644 index 000000000..748488383 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/assets/screenshots/xlsx4.png differ diff --git a/hr_attendance_xlsx_report/static/description/banner.png b/hr_attendance_xlsx_report/static/description/banner.png new file mode 100644 index 000000000..8b1bf1786 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/banner.png differ diff --git a/hr_attendance_xlsx_report/static/description/icon.png b/hr_attendance_xlsx_report/static/description/icon.png new file mode 100644 index 000000000..2a724a911 Binary files /dev/null and b/hr_attendance_xlsx_report/static/description/icon.png differ diff --git a/hr_attendance_xlsx_report/static/description/index.html b/hr_attendance_xlsx_report/static/description/index.html new file mode 100644 index 000000000..e0d843e23 --- /dev/null +++ b/hr_attendance_xlsx_report/static/description/index.html @@ -0,0 +1,609 @@ +
+
+
+
+ +
+
+
+ Community +
+
+
+
+
+ +
+
+
+

+ Employee Attendance Xlsx Report

+

+ This module helps to manage the attendance report of employees +

+ +
+
+ + + +
+
+

+ Overview +

+
+ +
+

+ This module helps to manage the attendance report of employees. + The report will show the working hours of each employee with the dates. + It helps to identify that whether the employee was present or not, or + working half day, by giving specific colors for each. +

+
+ +
+ + +
+
+

+ Features +

+
+ +
+
+ +
+
+

+ Attendance report of all employees

+
+
+ +
+
+ +
+
+

+ Attendance report of one specific employee

+
+
+ +
+ +
+
+

+ Screenshots +

+
+
+

+ Choose date range from wizard

+

+ Go to Attendance -> Reporting -> Attendance Report

+ +
+ +
+

+ Attendance report of all employees. +

+ +
+ +
+

+ Choose date range and employee from wizard. +

+ +
+ +
+

+ Attendance report of a chosen employee with a specified date range. +

+ +
+
+ +
+
+

Suggested Products

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

Our Services

+
+
+ +
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ 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

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

Need Help?

+
+
+
+ + +
+ +
+ + +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ + +
\ No newline at end of file diff --git a/hr_attendance_xlsx_report/static/src/js/action_manager.js b/hr_attendance_xlsx_report/static/src/js/action_manager.js new file mode 100644 index 000000000..fdf1a544f --- /dev/null +++ b/hr_attendance_xlsx_report/static/src/js/action_manager.js @@ -0,0 +1,24 @@ +/** @odoo-module */ +import { registry } from "@web/core/registry"; +import { download } from "@web/core/network/download"; +import framework from 'web.framework'; +import session from 'web.session'; + +/** + * @override + * Add 'xlsx' report type to the report handler + */ +registry.category("ir.actions.report handlers").add("xlsx", async (action) => { + if (action.report_type === 'xlsx') { + framework.blockUI(); + var def = $.Deferred(); + session.get_file({ + url: '/xlsx_reports', + data: action.data, + success: def.resolve.bind(def), + error: (error) => this.call('crash_manager', 'rpc_error', error), + complete: framework.unblockUI, + }); + return def; + } +}); \ No newline at end of file diff --git a/hr_attendance_xlsx_report/wizard/__init__.py b/hr_attendance_xlsx_report/wizard/__init__.py new file mode 100644 index 000000000..7e65e6681 --- /dev/null +++ b/hr_attendance_xlsx_report/wizard/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: LAJINA KV (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 employee_attendance_report diff --git a/hr_attendance_xlsx_report/wizard/employee_attendance_report.py b/hr_attendance_xlsx_report/wizard/employee_attendance_report.py new file mode 100644 index 000000000..c30374d58 --- /dev/null +++ b/hr_attendance_xlsx_report/wizard/employee_attendance_report.py @@ -0,0 +1,198 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: LAJINA KV (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 io +import json +from datetime import datetime +from dateutil.rrule import rrule, DAILY + +from odoo import fields, models, _ +from odoo.exceptions import ValidationError +from odoo.tools import date_utils + +try: + from odoo.tools.misc import xlsxwriter +except ImportError: + import xlsxwriter + + +class HrAttendanceReport(models.TransientModel): + """ Wizard for Employee Attendance Report """ + _name = 'employee.attendance.report' + _description = 'Employee Attendance Report Wizard' + + from_date = fields.Date('From Date', required=True) + to_date = fields.Date('To Date', required=True) + employee_ids = fields.Many2many('hr.employee', string='Employee', + help='Name of Employee') + + def action_print_xlsx(self): + """ + Returns report action for the XLSX Attendance report + Raises: ValidationError: if From Date > To Date + Raises: ValidationError: if there is no attendance records + Returns: + dict: the XLSX report action + """ + if self.from_date > self.to_date: + raise ValidationError(_('From Date must be earlier than To Date.')) + attendances = self.env['hr.attendance'].search( + [('employee_id', 'in', self.employee_ids.ids)]) + data = { + 'from_date': self.from_date, + 'to_date': self.to_date, + 'employee_ids': self.employee_ids.ids + } + if self.employee_ids and not attendances: + raise ValidationError( + _("There is no attendance records for the employee")) + if self.from_date and self.to_date: + return { + 'type': 'ir.actions.report', + 'data': {'model': 'employee.attendance.report', + 'options': json.dumps( + data, default=date_utils.json_default), + 'output_format': 'xlsx', + 'report_name': 'Attendance Report', + }, + 'report_type': 'xlsx', + } + + def get_xlsx_report(self, data, response): + """ + Print the XLSX report + Returns: None + """ + if not data['employee_ids']: + query = """select hr_e.name,date(hr_at.check_in), + SUM(hr_at.worked_hours) from hr_attendance hr_at LEFT JOIN + hr_employee hr_e ON hr_at.employee_id = hr_e.id + GROUP BY date(check_in), hr_e.name""" + self.env.cr.execute(query) + docs = self.env.cr.dictfetchall() + else: + query = """select hr_e.name,date(hr_at.check_in), + SUM(hr_at.worked_hours) from hr_attendance hr_at LEFT JOIN + hr_employee hr_e ON hr_at.employee_id = hr_e.id WHERE + hr_e.id in (%s) GROUP BY date(check_in), hr_e.name""" % (', '.join( + str(empolyee_id) for empolyee_id in data['employee_ids'])) + self.env.cr.execute(query) + docs = self.env.cr.dictfetchall() + output = io.BytesIO() + workbook = xlsxwriter.Workbook(output, {'in_memory': True}) + sheet = workbook.add_worksheet('docs') + start_date = datetime.strptime(data['from_date'], '%Y-%m-%d').date() + end_date = datetime.strptime(data['to_date'], '%Y-%m-%d').date() + date_range = rrule(DAILY, dtstart=start_date, until=end_date) + sheet.set_column(1, 1, 15) + sheet.set_column(2, 2, 15) + border = workbook.add_format({'border': 1}) + green = workbook.add_format({'bg_color': '#28A828', 'border': 1}) + red = workbook.add_format({'bg_color': '#ff3333', 'border': 1}) + rose = workbook.add_format({'bg_color': '#DA70D6', 'border': 1}) + head = workbook.add_format( + {'bold': True, 'font_size': 30, 'align': 'center'}) + sheet.merge_range('C3:K6', 'Attendance Report', head) + sheet.write(2, 12, '', green) + sheet.write(2, 13, 'Present') + sheet.write(4, 12, '', red) + sheet.write(4, 13, 'Absent') + sheet.write(6, 12, '', rose) + sheet.write(6, 13, 'Half Day') + sheet.merge_range('B13:B14', 'Sl.No', border) + sheet.merge_range('C13:C14', 'Employee', border) + row = 12 + col = 2 + for date_data in date_range: + col += 1 + sheet.write(row, col, date_data.strftime('%Y-%m-%d'), border) + row = 13 + col = 2 + for date_data in date_range: + col += 1 + sheet.write(row, col, date_data.strftime('%a'), border) + employee_names = [] + attendance_list = [] + for doc in docs: + if len(employee_names) >= 1: + if doc['name'] not in employee_names: + date_sum_list = [] + employee_names.append(doc['name']) + for date_data in date_range: + date_out = date_data.strftime('%Y-%m-%d') + record_list = list( + filter( + lambda x: x['name'] == doc['name'] and x[ + 'date'].strftime( + '%Y-%m-%d') == date_out, docs)) + if record_list: + date_sum_list.append(record_list[0]) + else: + date_sum_list.append({ + 'name': '', + 'date': '', + 'sum': 0 + }) + attendance_list.append( + {'name': doc['name'], 'items': date_sum_list}) + else: + date_sum_list = [] + employee_names.append(doc['name']) + for date_data in date_range: + date_out = date_data.strftime('%Y-%m-%d') + record_list = list( + filter( + lambda x: x['name'] == doc['name'] and x[ + 'date'].strftime( + '%Y-%m-%d') == date_out, docs)) + if record_list: + date_sum_list.append(record_list[0]) + else: + date_sum_list.append({ + 'name': '', + 'date': '', + 'sum': 0 + }) + attendance_list.append( + {'name': doc['name'], 'items': date_sum_list}) + work = self.env.ref('resource.resource_calendar_std') + row = 14 + i = 0 + for rec in attendance_list: + row += 1 + col = 1 + i += 1 + sheet.write(row, col, i, border) + col += 1 + sheet.write(row, col, rec['name'], border) + for item in rec['items']: + col += 1 + if item['sum'] >= work.hours_per_day: + sheet.write(row, col, item['sum'], green) + elif 1 <= item['sum'] <= 4 or 4 <= item['sum'] <= work.hours_per_day: + sheet.write(row, col, item['sum'], rose) + else: + sheet.write(row, col, item['sum'], red) + workbook.close() + output.seek(0) + response.stream.write(output.read()) + output.close() diff --git a/hr_attendance_xlsx_report/wizard/employee_attendance_report_views.xml b/hr_attendance_xlsx_report/wizard/employee_attendance_report_views.xml new file mode 100644 index 000000000..87c1d13ae --- /dev/null +++ b/hr_attendance_xlsx_report/wizard/employee_attendance_report_views.xml @@ -0,0 +1,41 @@ + + + + + employee.attendance.report.view.form + employee.attendance.report + +
+ + + + + + + + + +
+
+
+
+
+ + + Attendance Report + ir.actions.act_window + employee.attendance.report + form + + new + + + + +
\ No newline at end of file