diff --git a/visa_expiration/README.rst b/visa_expiration/README.rst new file mode 100644 index 000000000..3ffecf036 --- /dev/null +++ b/visa_expiration/README.rst @@ -0,0 +1,20 @@ +Visa Expiration Notification By E-mail v8 +========================================= + +This module will alert the employees on visa expiry. + +cron job +======== +This module add a cron job to invoke the email service. + +Configuration +============= +You should configure the outgoing mail server and provide valid email id for users. + +Credits +======= +Cybrosys Techno Solutions + +Author +====== +* Cybrosys Techno Solutions \ No newline at end of file diff --git a/visa_expiration/__init__.py b/visa_expiration/__init__.py new file mode 100644 index 000000000..03ebafd51 --- /dev/null +++ b/visa_expiration/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2015-TODAY Cybrosys Technologies(). +# Author: Sreejith P() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + +import models diff --git a/visa_expiration/__openerp__.py b/visa_expiration/__openerp__.py new file mode 100644 index 000000000..326dc1d1f --- /dev/null +++ b/visa_expiration/__openerp__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2015-TODAY Cybrosys Technologies(). +# Author: Sreejith P() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + +{ + 'name': 'Visa Expiration Notification By E-mail', + 'version': '8.0.1.0.0', + 'category': 'Human Resource', + 'summary': 'Alert on Visa expiry date based on settings in employee contract form.', + 'sequence': 55, + 'author': 'Cybrosys techno solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['hr_contract'], + 'data': [ + 'views/email.xml', + 'views/settings_hr.xml' + ], + 'test': [], + 'license': 'AGPL-3', + 'images': ['static/description/banner.jpg'], + 'installable': True, + 'auto_install': False, +} diff --git a/visa_expiration/models/__init__.py b/visa_expiration/models/__init__.py new file mode 100644 index 000000000..cad11c3bb --- /dev/null +++ b/visa_expiration/models/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2015-TODAY Cybrosys Technologies(). +# Author: Sreejith P() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + +import email +import settings_hr \ No newline at end of file diff --git a/visa_expiration/models/email.py b/visa_expiration/models/email.py new file mode 100644 index 000000000..b0f6018cb --- /dev/null +++ b/visa_expiration/models/email.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +from openerp import models +from datetime import datetime, timedelta + + +class ReminderVisa(models.Model): + _inherit = 'hr.contract' + + def mail_reminder(self, cr, uid, context=None): + i = self.pool.get('hr.config.settings').search(cr, uid, [], limit=1, order='id desc') + x = self.pool.get('hr.config.settings').browse(cr, uid, i and i[0], context) + if x.visa_validity != False: + tommorrow = datetime.now()+timedelta(days=x.limit_amount) + date_tommorrow = tommorrow.date() + issue_obj = self.pool.get('hr.contract') + match = issue_obj.search(cr, uid, [('visa_expire', '<=', date_tommorrow)]) + for i in match: + browse_hr_contract = issue_obj.browse(cr, uid, i) + browse_id = browse_hr_contract.employee_id + self.send_email_employee(cr, uid, browse_id.id, browse_id.name, browse_hr_contract.visa_expire, + date_tommorrow, context) + else: + pass + + def send_email_employee(self, cr, uid, emp_id, emp_name, exp_date, no_days, context=None): + email_template_obj = self.pool.get('email.template') + template_ids = email_template_obj.search(cr, uid, [('name', '=', 'Visa Alert Email For Employees')], context=context) + template_brwse = email_template_obj.browse(cr, uid, template_ids) + email_to = self.pool.get('hr.employee').browse(cr, uid, emp_id, context).work_email + body_html = " Hello "+emp_name+",
Your visa is going to expire on "+str(exp_date) +\ + ". Please renew it before expiry date" + if template_ids: + values = email_template_obj.generate_email(cr, uid, template_ids[0], emp_id, context=context) + values['subject'] = template_brwse.subject + values['email_to'] = email_to + values['body_html'] = body_html + values['body'] = body_html + values['email_from'] = template_brwse.email_from + values['res_id'] = False + mail_mail_obj = self.pool.get('mail.mail') + msg_id = mail_mail_obj.create(cr, uid, values, context=context) + if msg_id: + mail_mail_obj.send(cr, uid, [msg_id], context=context) + return True diff --git a/visa_expiration/models/settings_hr.py b/visa_expiration/models/settings_hr.py new file mode 100644 index 000000000..1a4e31813 --- /dev/null +++ b/visa_expiration/models/settings_hr.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from openerp.osv import fields, osv + + +class SettingOption(osv.osv_memory): + _inherit = 'hr.config.settings' + _columns = { + 'visa_validity': fields.boolean("Get email notification on employee VISA expiration", + help="""Allow to define from how many days before to start alert + Employee and other configured addresses will get the notification emails each day."""), + 'limit_amount': fields.integer("from", size=10) + } + + def get_default_visa_details(self, cr, uid, fields, context=None): + ir_values = self.pool.get('ir.values') + visa_validity = ir_values.get_default(cr, uid, 'sale.config.settings', 'visa_validity') + limit_amount = ir_values.get_default(cr, uid, 'sale.config.settings', 'limit_amount') + return {'visa_validity': visa_validity, 'limit_amount': limit_amount} diff --git a/visa_expiration/static/description/banner.jpg b/visa_expiration/static/description/banner.jpg new file mode 100644 index 000000000..aa55eda60 Binary files /dev/null and b/visa_expiration/static/description/banner.jpg differ diff --git a/visa_expiration/static/description/contract_form.png b/visa_expiration/static/description/contract_form.png new file mode 100644 index 000000000..7296fba0d Binary files /dev/null and b/visa_expiration/static/description/contract_form.png differ diff --git a/visa_expiration/static/description/cybro_logo.png b/visa_expiration/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/visa_expiration/static/description/cybro_logo.png differ diff --git a/visa_expiration/static/description/employee_form.png b/visa_expiration/static/description/employee_form.png new file mode 100644 index 000000000..dfdc1d317 Binary files /dev/null and b/visa_expiration/static/description/employee_form.png differ diff --git a/visa_expiration/static/description/hr_config.png b/visa_expiration/static/description/hr_config.png new file mode 100644 index 000000000..47dbcf573 Binary files /dev/null and b/visa_expiration/static/description/hr_config.png differ diff --git a/visa_expiration/static/description/icon.png b/visa_expiration/static/description/icon.png new file mode 100644 index 000000000..8b173b38e Binary files /dev/null and b/visa_expiration/static/description/icon.png differ diff --git a/visa_expiration/static/description/index.html b/visa_expiration/static/description/index.html new file mode 100644 index 000000000..4c0b5765b --- /dev/null +++ b/visa_expiration/static/description/index.html @@ -0,0 +1,96 @@ +
+
+

Visa Expiration Notification By E-mail

+

This module will alert the employees on visa expiry.

+ +

Author : Cybrosys Techno Solutions , www.cybrosys.com

+
+

Features:

+
    +
  •    Adds a cron job to invoke email
  • +
  •    Adds an email template for employees
  • +
+
+
+
+ +
+
+
+

Overview

+

+ You will not miss out of the visa expiry date anymore. + This module provides you the option to set alert on Visa expiry date that will remind employee for renewal. + You will be notified of the expiry date of the Visa as per the prior number of days being set in the HR configuration.

+
+
+
+ +
+
+

Employee Form

+
+

+ ☛ Give work email.
+

+
+ +
+
+
+
+ +
+
+

Contract Form

+
+

+ ☛ Give visa Expiry Date
+

+
+ +
+
+
+
+ +
+
+

HR Configuration

+
+

+ ☛ Tick "Get email notification on employee VISA expiration"
+ ☛ Once you enable the option you get a field to configure the number of days before which you need the alert.
+

+
+ +
+
+
+
+ +
+

Need Any Help?

+ +
diff --git a/visa_expiration/views/email.xml b/visa_expiration/views/email.xml new file mode 100644 index 000000000..1dd68dcd5 --- /dev/null +++ b/visa_expiration/views/email.xml @@ -0,0 +1,21 @@ + + + + + HR Employee Visa Expiration + 1 + days + -1 + + + + + + + Visa Alert Email For Employees + + Notification About Your Visa Expiry Date + ${object.employee_id.company_id.email or object.employee_id.user_id.user_email or 'noreply@localhost'} + + + diff --git a/visa_expiration/views/settings_hr.xml b/visa_expiration/views/settings_hr.xml new file mode 100644 index 000000000..963370a53 --- /dev/null +++ b/visa_expiration/views/settings_hr.xml @@ -0,0 +1,26 @@ + + + + + set.option.form + hr.config.settings + + + + + +
+ +
+ +
+
+
+
+
\ No newline at end of file