diff --git a/hr_leave_request_aliasing/README.md b/hr_leave_request_aliasing/README.md new file mode 100644 index 000000000..bbebcea82 --- /dev/null +++ b/hr_leave_request_aliasing/README.md @@ -0,0 +1,25 @@ +Open HRMS 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. + +Technical Notes +--------------- + +Here you need to send leave request through email with the following rules. +* You must send leave request through your registered email id. +* Mail subject must be start with 'LEAVE REQUEST ' +* Mail body must contain date as per given format (%d/%m/%Y) + +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/__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..7dcaee642 --- /dev/null +++ b/hr_leave_request_aliasing/__manifest__.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of Open HRMS 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': 'Open HRMS Leave Request Aliasing', + 'version': '11.0.1.0.0', + 'summary': """Allows You To Create Leave Request Automatically From Incoming Mails""", + 'description': 'This module allows you to create leave request directly 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/doc/RELEASE_NOTES.md b/hr_leave_request_aliasing/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..d8cbf249f --- /dev/null +++ b/hr_leave_request_aliasing/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 24.03.2018 +#### Version 11.0.1.0.0 +##### ADD +- Initial commit for Open HRMS Project 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/__init__.pyc b/hr_leave_request_aliasing/models/__init__.pyc new file mode 100644 index 000000000..e57e06aa2 Binary files /dev/null and b/hr_leave_request_aliasing/models/__init__.pyc differ diff --git a/hr_leave_request_aliasing/models/__pycache__/__init__.cpython-35.pyc b/hr_leave_request_aliasing/models/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 000000000..0e1b707d6 Binary files /dev/null and b/hr_leave_request_aliasing/models/__pycache__/__init__.cpython-35.pyc differ diff --git a/hr_leave_request_aliasing/models/__pycache__/leave_request_alias.cpython-35.pyc b/hr_leave_request_aliasing/models/__pycache__/leave_request_alias.cpython-35.pyc new file mode 100644 index 000000000..9bcfd4d4a Binary files /dev/null and b/hr_leave_request_aliasing/models/__pycache__/leave_request_alias.cpython-35.pyc differ diff --git a/hr_leave_request_aliasing/models/__pycache__/res_config.cpython-35.pyc b/hr_leave_request_aliasing/models/__pycache__/res_config.cpython-35.pyc new file mode 100644 index 000000000..c4b0aa136 Binary files /dev/null and b/hr_leave_request_aliasing/models/__pycache__/res_config.cpython-35.pyc differ diff --git a/hr_leave_request_aliasing/models/__pycache__/web_planner.cpython-35.pyc b/hr_leave_request_aliasing/models/__pycache__/web_planner.cpython-35.pyc new file mode 100644 index 000000000..f69ca2b3b Binary files /dev/null and b/hr_leave_request_aliasing/models/__pycache__/web_planner.cpython-35.pyc differ 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/leave_request_alias.pyc b/hr_leave_request_aliasing/models/leave_request_alias.pyc new file mode 100644 index 000000000..20a57a492 Binary files /dev/null and b/hr_leave_request_aliasing/models/leave_request_alias.pyc differ 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..58df9c676 --- /dev/null +++ b/hr_leave_request_aliasing/models/res_config.py @@ -0,0 +1,48 @@ +# -*- 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): + _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', help='Default Alias Domain for Leave', + default=lambda self: self.env["ir.config_parameter"].get_param("mail.catchall.domain")) + + def set_values(self): + super(HrLeaveConfigSettings, self).set_values() + set_param = self.env['ir.config_parameter'].set_param + set_param('alias_prefix', self.alias_prefix) + set_param('alias_domain', self.alias_domain ) + + @api.model + def get_values(self): + res = super(HrLeaveConfigSettings, self).get_values() + get_param = self.env['ir.config_parameter'].sudo().get_param + res.update( + alias_prefix=get_param('alias_prefix', default=''), + alias_domain=get_param('alias_domain', default=''), + ) + return res + diff --git a/hr_leave_request_aliasing/models/res_config.pyc b/hr_leave_request_aliasing/models/res_config.pyc new file mode 100644 index 000000000..f9621da98 Binary files /dev/null and b/hr_leave_request_aliasing/models/res_config.pyc differ 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..e62a026d5 --- /dev/null +++ b/hr_leave_request_aliasing/models/web_planner.py @@ -0,0 +1,44 @@ +# -*- 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): + """This class is used to activate web.planner feature in 'hr_leave_request_aliasing' module""" + + _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/models/web_planner.pyc b/hr_leave_request_aliasing/models/web_planner.pyc new file mode 100644 index 000000000..8a7a9c706 Binary files /dev/null and b/hr_leave_request_aliasing/models/web_planner.pyc differ 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..6c368f8a3 --- /dev/null +++ b/hr_leave_request_aliasing/static/description/index.html @@ -0,0 +1,102 @@ +
+
+

Open HRMS

+

Most advanced open source HR management software

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

Open HRMS Leave Request Aliasing

+

Creating Leave Request, Automatically From Incoming Emails

+

Cybrosys Technologies

+
+
+

Features:

+
+ Automation on Leaves Request Mails.
+ 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. +

+
+
+
+ +
+
+
+
+ +
+ + Here we can send leave request through our registered email id. Then it will create leave + request in Odoo. We must ensure that our mail subject must start with 'LEAVE REQUEST ' and date + format must be as '%d/%m/%Y'. + +
+
+
+ + +
+
+

Our Odoo Services

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

Need Any Help?

+ +
\ No newline at end of file diff --git a/hr_leave_request_aliasing/static/description/mail_aliasing.png b/hr_leave_request_aliasing/static/description/mail_aliasing.png new file mode 100644 index 000000000..5b499b18a Binary files /dev/null and b/hr_leave_request_aliasing/static/description/mail_aliasing.png differ 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..ac02c9c68 --- /dev/null +++ b/hr_leave_request_aliasing/views/res_config_views.xml @@ -0,0 +1,54 @@ + + + + + Configure Leave + res.config.settings + + + + +
+

Leaves

+
+
+
+
+
+
+
+
+
+
+ + + Leaves Config + ir.actions.act_window + res.config.settings + form + inline + {'module' : 'hr_leave_request_aliasing'} + + + +
+