diff --git a/hr_leave_request_aliasing/README.md b/hr_leave_request_aliasing/README.md new file mode 100644 index 000000000..a2f71636d --- /dev/null +++ b/hr_leave_request_aliasing/README.md @@ -0,0 +1,17 @@ +OHRMS Leave Request Aliasing +---------------------------- +Supporting Addon for Open HRMS, Allows You To Create Leave Request Automatically From Incoming Emails + +Connect with experts +-------------------- + +If you have any question/queries/additional works on OpenHRMS or this module, You can drop an email directly to Cybrosys. + +Contacts +-------- +info - info@cybrosys.com +Jesni Banu - jesni@cybrosys.in + +Website: +https://www.openhrms.com +https://www.cybrosys.com diff --git a/hr_leave_request_aliasing/RELEASE_NOTES.md b/hr_leave_request_aliasing/RELEASE_NOTES.md new file mode 100644 index 000000000..406ed1b41 --- /dev/null +++ b/hr_leave_request_aliasing/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 30.03.2018 +#### Version 10.0.1.0.0 +##### ADD +- Initial commit for OpenHrms Project diff --git a/hr_leave_request_aliasing/__init__.py b/hr_leave_request_aliasing/__init__.py new file mode 100644 index 000000000..b579ce91c --- /dev/null +++ b/hr_leave_request_aliasing/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Jesni Banu () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### +from . import models + + diff --git a/hr_leave_request_aliasing/__manifest__.py b/hr_leave_request_aliasing/__manifest__.py new file mode 100644 index 000000000..0af7ff4cb --- /dev/null +++ b/hr_leave_request_aliasing/__manifest__.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Jesni Banu () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### +{ + 'name': 'OHRMS Leave Request Aliasing', + 'version': '10.0.1.0.0', + 'summary': """Allows You To Create Leave Request Automatically From Incoming Emails""", + 'description': 'This module allows you to create leave request automatically from incoming mails.', + 'category': 'Generic Modules/Human Resources', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': "https://www.openhrms.com", + 'depends': ['base_setup', 'hr_holidays'], + 'data': [ + 'data/web_planner_data.xml', + 'views/hr_leave_template.xml', + 'views/leave_request_alias_view.xml', + 'views/res_config_views.xml', + ], + 'demo': [], + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/hr_leave_request_aliasing/data/web_planner_data.xml b/hr_leave_request_aliasing/data/web_planner_data.xml new file mode 100644 index 000000000..c21ce1667 --- /dev/null +++ b/hr_leave_request_aliasing/data/web_planner_data.xml @@ -0,0 +1,81 @@ + + + + + + Leave strategy planner + + + planner_hr_leave + + + + diff --git a/hr_leave_request_aliasing/models/__init__.py b/hr_leave_request_aliasing/models/__init__.py new file mode 100644 index 000000000..79435f83b --- /dev/null +++ b/hr_leave_request_aliasing/models/__init__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Jesni Banu () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### +from . import leave_request_alias +from . import res_config +from . import web_planner + + diff --git a/hr_leave_request_aliasing/models/leave_request_alias.py b/hr_leave_request_aliasing/models/leave_request_alias.py new file mode 100644 index 000000000..2e326c22b --- /dev/null +++ b/hr_leave_request_aliasing/models/leave_request_alias.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Jesni Banu () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### +import re +from datetime import datetime, timedelta +from odoo import models, api +from odoo.tools import email_split + + +class HrLeaveAlias(models.Model): + _inherit = 'hr.holidays' + + @api.model + def message_new(self, msg_dict, custom_values=None): + """This function extracts required fields of hr.holidays from incoming mail then creating records""" + try: + if custom_values is None: + custom_values = {} + msg_subject = msg_dict.get('subject', '') + subject = re.search('LEAVE REQUEST', msg_subject) + if subject is not None: + email_address = email_split(msg_dict.get('email_from', False))[0] + employee = self.env['hr.employee'].sudo().search([ + '|', + ('work_email', 'ilike', email_address), + ('user_id.email', 'ilike', email_address) + ], limit=1) + msg_body = msg_dict.get('body', '') + cleaner = re.compile('<.*?>') + clean_msg_body = re.sub(cleaner, '', msg_body) + date_list = re.findall(r'\d{2}/\d{2}/\d{4}', clean_msg_body) + if len(date_list) > 0: + date_from = date_list[0] + if len(date_list) > 1: + start_date = datetime.strptime(date_list[1], '%d/%m/%Y') + date_to = start_date + timedelta(days=0) + else: + start_date = datetime.strptime(date_list[0], '%d/%m/%Y') + date_to = start_date + timedelta(days=1) + no_of_days_temp = (datetime.strptime(str(date_to), "%Y-%m-%d %H:%M:%S") - + datetime.strptime(date_from, '%d/%m/%Y')).days + custom_values.update({ + 'name': msg_subject.strip(), + 'employee_id': employee.id, + 'holiday_status_id': 1, + 'date_from': date_from, + 'date_to': date_to, + 'no_of_days_temp': no_of_days_temp + }) + return super(HrLeaveAlias, self).message_new(msg_dict, custom_values) + except: + pass + + diff --git a/hr_leave_request_aliasing/models/res_config.py b/hr_leave_request_aliasing/models/res_config.py new file mode 100644 index 000000000..6c2175a69 --- /dev/null +++ b/hr_leave_request_aliasing/models/res_config.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Jesni Banu () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### +from odoo import api, fields, models + + +class HrLeaveConfigSettings(models.TransientModel): + _name = 'hr.leave.config.settings' + _inherit = 'res.config.settings' + + alias_prefix = fields.Char(string='Default Alias Name for Leave', help='Default Alias Name for Leave') + alias_domain = fields.Char(string='Alias Domain', + default=lambda self: self.env["ir.config_parameter"].get_param("mail.catchall.domain")) + + @api.model + def get_default_alias_prefix(self, fields): + alias_name = self.env.ref('hr_leave_request_aliasing.mail_alias_leave').alias_name + return {'alias_prefix': alias_name} + + @api.multi + def set_default_alias_prefix(self): + for record in self: + self.env.ref('hr_leave_request_aliasing.mail_alias_leave').write({'alias_name': record.alias_prefix}) + diff --git a/hr_leave_request_aliasing/models/web_planner.py b/hr_leave_request_aliasing/models/web_planner.py new file mode 100644 index 000000000..92705f3a9 --- /dev/null +++ b/hr_leave_request_aliasing/models/web_planner.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Jesni Banu () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### +from odoo import api, models + + +class PlannerHrLeave(models.Model): + + _inherit = 'web.planner' + + @api.model + def _get_planner_application(self): + planner = super(PlannerHrLeave, self)._get_planner_application() + planner.append(['planner_hr_leave', 'Leave Planner']) + return planner + + @api.model + def _prepare_planner_hr_leave_data(self): + alias_record = self.env.ref('hr_leave_request_aliasing.mail_alias_leave') + return { + 'alias_domain': alias_record.alias_domain, + 'alias_name': alias_record.alias_name, + } + diff --git a/hr_leave_request_aliasing/static/description/HRMS-BUTTON.png b/hr_leave_request_aliasing/static/description/HRMS-BUTTON.png new file mode 100644 index 000000000..0f1b65bea Binary files /dev/null and b/hr_leave_request_aliasing/static/description/HRMS-BUTTON.png differ diff --git a/hr_leave_request_aliasing/static/description/banner.jpg b/hr_leave_request_aliasing/static/description/banner.jpg new file mode 100644 index 000000000..06286d846 Binary files /dev/null and b/hr_leave_request_aliasing/static/description/banner.jpg differ diff --git a/hr_leave_request_aliasing/static/description/cybro-service.png b/hr_leave_request_aliasing/static/description/cybro-service.png new file mode 100644 index 000000000..252929a86 Binary files /dev/null and b/hr_leave_request_aliasing/static/description/cybro-service.png differ diff --git a/hr_leave_request_aliasing/static/description/cybro_logo.png b/hr_leave_request_aliasing/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/hr_leave_request_aliasing/static/description/cybro_logo.png differ diff --git a/hr_leave_request_aliasing/static/description/icon.png b/hr_leave_request_aliasing/static/description/icon.png new file mode 100644 index 000000000..2ebe3a208 Binary files /dev/null and b/hr_leave_request_aliasing/static/description/icon.png differ diff --git a/hr_leave_request_aliasing/static/description/index.html b/hr_leave_request_aliasing/static/description/index.html new file mode 100644 index 000000000..08f644845 --- /dev/null +++ b/hr_leave_request_aliasing/static/description/index.html @@ -0,0 +1,62 @@ +
+
+

OpenHRMS

+

Most advanced open source HR management software

+
+
+
+
+

OH Leave Request Aliasing

+

This Module Allows You To Create Leave Request Automatically Directly From Incoming Emails

+

Cybrosys Technologies

+
+
+

Features:

+
+ Creating leave request automatically from incoming email.
+ Option to set aliasing domain separately for leave request.
+
+
+
+ +
+
+
+

Overview

+

+ Email aliasing is a default feature in Odoo which allows the user to fetch contents to ERP records directly from incoming emails. + The feature is a type of automation. Since we can configure the E-mails to fetch contents directly. + So here we are providing one of the new module to create leave request automatically from incoming email. +

+
+
+
+ + +
+
+

Our Odoo Services

+ + +
+ +
+ +
+

Need Any Help?

+ +
\ No newline at end of file diff --git a/hr_leave_request_aliasing/static/src/js/web_planner_hr_leave.js b/hr_leave_request_aliasing/static/src/js/web_planner_hr_leave.js new file mode 100644 index 000000000..f05102334 --- /dev/null +++ b/hr_leave_request_aliasing/static/src/js/web_planner_hr_leave.js @@ -0,0 +1,6 @@ +odoo.define('planner_hr_leave.planner', function (require) { +"use strict"; + +var planner = require('web.planner.common'); + +}); diff --git a/hr_leave_request_aliasing/views/hr_leave_template.xml b/hr_leave_request_aliasing/views/hr_leave_template.xml new file mode 100644 index 000000000..46bd54628 --- /dev/null +++ b/hr_leave_request_aliasing/views/hr_leave_template.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/hr_leave_request_aliasing/views/leave_request_alias_view.xml b/hr_leave_request_aliasing/views/leave_request_alias_view.xml new file mode 100644 index 000000000..f4430dc30 --- /dev/null +++ b/hr_leave_request_aliasing/views/leave_request_alias_view.xml @@ -0,0 +1,9 @@ + + + + leave + + + employees + + diff --git a/hr_leave_request_aliasing/views/res_config_views.xml b/hr_leave_request_aliasing/views/res_config_views.xml new file mode 100644 index 000000000..0ad909589 --- /dev/null +++ b/hr_leave_request_aliasing/views/res_config_views.xml @@ -0,0 +1,50 @@ + + + + + Configure Leave + hr.leave.config.settings + + +
+
+
+ + +
+
+
+ + + Configure Leave + hr.leave.config.settings + form + inline + + + +
+