diff --git a/hr_reminder/__init__.py b/hr_reminder/__init__.py new file mode 100644 index 000000000..a84ea577e --- /dev/null +++ b/hr_reminder/__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: Treesa Maria Jude () +# +# 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 +from . import controllers diff --git a/hr_reminder/__manifest__.py b/hr_reminder/__manifest__.py new file mode 100644 index 000000000..bcae35494 --- /dev/null +++ b/hr_reminder/__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: Treesa Maria Jude () +# +# 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 Reminders Todo', + 'version': '10.0.1.0.0', + 'category': 'Extra Tools', + 'summary': 'HR Reminder', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': "https://www.openhrms.com", + 'depends': ['base', 'hr'], + 'data': [ + 'security/ir.model.access.csv', + 'security/hr_reminder_security.xml', + 'views/hr_reminder_view.xml', + 'views/reminder_template.xml', + ], + 'qweb': [ + 'static/src/xml/reminder_topbar.xml', ], + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/hr_reminder/controllers/__init__.py b/hr_reminder/controllers/__init__.py new file mode 100644 index 000000000..4ba08ec91 --- /dev/null +++ b/hr_reminder/controllers/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Treesa Maria Jude () +# +# 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 main diff --git a/hr_reminder/controllers/main.py b/hr_reminder/controllers/main.py new file mode 100644 index 000000000..bfb960dee --- /dev/null +++ b/hr_reminder/controllers/main.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Treesa Maria Jude () +# +# 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 http +from odoo.http import request + + +class Reminders(http.Controller): + + @http.route('/hr_reminder/all_reminder', type='json', auth="public") + def all_reminder(self): + reminder = [] + for i in request.env['hr.reminder'].search([]): + if i.reminder_active: + reminder.append(i.name) + return reminder + + @http.route('/hr_reminder/reminder_active', type='json', auth="public") + def reminder_active(self, **kwargs): + reminder_value = kwargs.get('reminder_name') + value = [] + + for i in request.env['hr.reminder'].search([('name', '=', reminder_value)]): + value.append(i.model_name.model) + value.append(i.model_field.name) + value.append(i.search_by) + value.append(i.date_set) + value.append(i.date_from) + value.append(i.date_to) + # value.append(i.exclude_year) + return value diff --git a/hr_reminder/controllers/time_reminder.py b/hr_reminder/controllers/time_reminder.py new file mode 100644 index 000000000..4dd40e492 --- /dev/null +++ b/hr_reminder/controllers/time_reminder.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import werkzeug + +from odoo.api import Environment +import odoo.http as http + +from odoo.http import request +from odoo import SUPERUSER_ID +from odoo import registry as registry_get + + +class CalendarController(http.Controller): + + @http.route('/calendar/meeting/accept', type='http', auth="calendar") + def accept(self, db, token, action, id, **kwargs): + registry = registry_get(db) + with registry.cursor() as cr: + env = Environment(cr, SUPERUSER_ID, {}) + attendee = env['calendar.attendee'].search([('access_token', '=', token), ('state', '!=', 'accepted')]) + if attendee: + attendee.do_accept() + return self.view(db, token, action, id, view='form') + + @http.route('/calendar/meeting/decline', type='http', auth="calendar") + def declined(self, db, token, action, id): + registry = registry_get(db) + with registry.cursor() as cr: + env = Environment(cr, SUPERUSER_ID, {}) + attendee = env['calendar.attendee'].search([('access_token', '=', token), ('state', '!=', 'declined')]) + if attendee: + attendee.do_decline() + return self.view(db, token, action, id, view='form') + + @http.route('/calendar/meeting/view', type='http', auth="calendar") + def view(self, db, token, action, id, view='calendar'): + registry = registry_get(db) + with registry.cursor() as cr: + # Since we are in auth=none, create an env with SUPERUSER_ID + env = Environment(cr, SUPERUSER_ID, {}) + attendee = env['calendar.attendee'].search([('access_token', '=', token)]) + timezone = attendee.partner_id.tz + lang = attendee.partner_id.lang or 'en_US' + event = env['calendar.event'].with_context(tz=timezone, lang=lang).browse(int(id)) + + # If user is logged, redirect to form view of event + # otherwise, display the simplifyed web page with event informations + if request.session.uid: + return werkzeug.utils.redirect('/web?db=%s#id=%s&view_type=form&model=calendar.event' % (db, id)) + + # NOTE : we don't use request.render() since: + # - we need a template rendering which is not lazy, to render before cursor closing + # - we need to display the template in the language of the user (not possible with + # request.render()) + return env['ir.ui.view'].with_context(lang=lang).render_template( + 'calendar.invitation_page_anonymous', { + 'event': event, + 'attendee': attendee, + }) + + # Function used, in RPC to check every 5 minutes, if notification to do for an event or not + @http.route('/calendar/notify', type='json', auth="user") + def notify(self): + return request.env['calendar.alarm_manager'].get_next_notif() + + @http.route('/calendar/notify_ack', type='json', auth="user") + def notify_ack(self, type=''): + return request.env['res.partner']._set_calendar_last_notif_ack() diff --git a/hr_reminder/models/__init__.py b/hr_reminder/models/__init__.py new file mode 100644 index 000000000..88311d898 --- /dev/null +++ b/hr_reminder/models/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Treesa Maria Jude () +# +# 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 hr_reminder diff --git a/hr_reminder/models/hr_reminder.py b/hr_reminder/models/hr_reminder.py new file mode 100644 index 000000000..f0d157455 --- /dev/null +++ b/hr_reminder/models/hr_reminder.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Treesa Maria Jude () +# +# 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 datetime import datetime +from odoo import models, fields + + +class HrPopupReminder(models.Model): + _name = 'hr.reminder' + + name = fields.Char(string='Title', required=True) + model_name = fields.Many2one('ir.model', string="Model", required=True, domain="[('model', 'like','hr')]") + model_field = fields.Many2one('ir.model.fields', string='Field', + domain="[('model_id', '=',model_name),('ttype', 'in', ['datetime','date'])]", + required=True) + search_by = fields.Selection([('today', 'Today'), + ('set_period', 'Set Period'), + ('set_date', 'Set Date'), ], + required=True, string="Search By") + days_before = fields.Integer(string='Reminder before') + active = fields.Boolean(string="Active",default=True) + # exclude_year = fields.Boolean(string="Consider day alone") + reminder_active = fields.Boolean(string="Reminder Active") + date_set = fields.Date(string='Select Date') + date_from = fields.Date(string="Start Date") + date_to = fields.Date(string="End Date") + expiry_date = fields.Date(string="Reminder Expiry Date") + company_id = fields.Many2one('res.company', string='Company', required=True, + default=lambda self: self.env.user.company_id) + + def reminder_scheduler(self): + now = fields.Datetime.from_string(fields.Datetime.now()) + today = fields.Date.today() + obj = self.env['hr.reminder'].search([]) + for i in obj: + if i.search_by != "today": + if i.expiry_date and datetime.strptime(today, "%Y-%m-%d") == datetime.strptime(i.expiry_date, "%Y-%m-%d"): + i.active = False + else: + if i.search_by == "set_date": + d1 = datetime.strptime(i.date_set, "%Y-%m-%d") + d2 = datetime.strptime(today, "%Y-%m-%d") + daydiff = abs((d2 - d1).days) + if daydiff <= i.days_before: + i.reminder_active = True + else: + i.reminder_active = False + elif i.search_by == "set_period": + d1 = datetime.strptime(i.date_from, "%Y-%m-%d") + d2 = datetime.strptime(today, "%Y-%m-%d") + daydiff = abs((d2 - d1).days) + if daydiff <= i.days_before: + i.reminder_active = True + else: + i.reminder_active = False + else: + i.reminder_active = True + + + diff --git a/hr_reminder/security/hr_reminder_security.xml b/hr_reminder/security/hr_reminder_security.xml new file mode 100644 index 000000000..2650c4fa0 --- /dev/null +++ b/hr_reminder/security/hr_reminder_security.xml @@ -0,0 +1,10 @@ + + + + Hr Reminder Company + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + + \ No newline at end of file diff --git a/hr_reminder/security/ir.model.access.csv b/hr_reminder/security/ir.model.access.csv new file mode 100644 index 000000000..46fc9f5d3 --- /dev/null +++ b/hr_reminder/security/ir.model.access.csv @@ -0,0 +1,5 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink + +access_hr_reminder_officer,hr.reminder.officer,hr_reminder.model_hr_reminder,hr.group_hr_user,1,1,1,1 +access_hr_reminder_employee,hr.reminder.employee,hr_reminder.model_hr_reminder,hr.group_hr_manager,1,1,1,1 +access_hr_reminder_manager,hr.reminder.manager,hr_reminder.model_hr_reminder,base.group_user,0,0,0,0 diff --git a/hr_reminder/static/description/banner.jpg b/hr_reminder/static/description/banner.jpg new file mode 100644 index 000000000..7579d32ea Binary files /dev/null and b/hr_reminder/static/description/banner.jpg differ diff --git a/hr_reminder/static/description/cybro-service.png b/hr_reminder/static/description/cybro-service.png new file mode 100644 index 000000000..252929a86 Binary files /dev/null and b/hr_reminder/static/description/cybro-service.png differ diff --git a/hr_reminder/static/description/cybro_logo.png b/hr_reminder/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/hr_reminder/static/description/cybro_logo.png differ diff --git a/hr_reminder/static/description/icon.png b/hr_reminder/static/description/icon.png new file mode 100644 index 000000000..cf84f5d5c Binary files /dev/null and b/hr_reminder/static/description/icon.png differ diff --git a/hr_reminder/static/description/index.html b/hr_reminder/static/description/index.html new file mode 100644 index 000000000..b16d11d76 --- /dev/null +++ b/hr_reminder/static/description/index.html @@ -0,0 +1,115 @@ +
+
+

OpenHRMS

+

Most advanced open source HR management software

+
+
+ +
+
+

Reminders

+

Cybrosys Technologies , www.cybrosys.com

+

+Reminders is an effective module,helps to memorise all your important dates. We +can set reminders to any model (eg: Sales,HR,Project etc..) and also their corresponding +date fields to compare.This eases the company work load to memorize the special +dates (eg: Expiration date,Deadline date,Assigned Date etc...). +

+
+
+ +
+
+

Set Your Reminders

+
+

+

Settings>Pop-up Reminder>Reminder

+

+

Set your reminders for any model and the corresponding date field. + Also this module allows different methods to search.

+

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

Search By

+
+

We can use 3 methods to search:

+
    +
  •    Today: Compares to the current date.
  • +
  •    Set Date: Compares with the given date.
  • +
  •    Set Period: Reminder is set between a time range(Start date - End date).
  • +
+
+
+
+

Set Date

+ +
+
+

Set Period

+ +
+
+
+ + +
+
+
+

Reminder Button

+

Select the Reminder from the list of Reminders

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

Related Result

+
+
+
+ +
+
+
+ +
+

Need Any Help?

+ +
+ + diff --git a/hr_reminder/static/description/popup.png b/hr_reminder/static/description/popup.png new file mode 100644 index 000000000..cf866f793 Binary files /dev/null and b/hr_reminder/static/description/popup.png differ diff --git a/hr_reminder/static/description/reminder.png b/hr_reminder/static/description/reminder.png new file mode 100644 index 000000000..3e199ffef Binary files /dev/null and b/hr_reminder/static/description/reminder.png differ diff --git a/hr_reminder/static/description/result.png b/hr_reminder/static/description/result.png new file mode 100644 index 000000000..2a74ff761 Binary files /dev/null and b/hr_reminder/static/description/result.png differ diff --git a/hr_reminder/static/description/set_date.png b/hr_reminder/static/description/set_date.png new file mode 100644 index 000000000..d5e253c15 Binary files /dev/null and b/hr_reminder/static/description/set_date.png differ diff --git a/hr_reminder/static/description/set_period.png b/hr_reminder/static/description/set_period.png new file mode 100644 index 000000000..da9da01d5 Binary files /dev/null and b/hr_reminder/static/description/set_period.png differ diff --git a/hr_reminder/static/src/css/notification.css b/hr_reminder/static/src/css/notification.css new file mode 100644 index 000000000..f40020454 --- /dev/null +++ b/hr_reminder/static/src/css/notification.css @@ -0,0 +1,31 @@ + +.oe_webclient_notification_action t { + color: white; +} +.oe_webclient_notification_action p { + color: white; + margin-top: 1em; +} + .label { + display: inline-block; + color: black; + max-width: 100%; + margin-bottom: 5px; + font-weight: bold; +} +.reminder-dropdown { + .o-flex(0, 1, auto); + background: #FFFFFF; + max-height: 400px; + min-height: 50px; + overflow-y: auto; + + @media (max-width: @screen-xs-max) { + max-height: none; + } + +.detail-client-address-country { + color: black; + } + + diff --git a/hr_reminder/static/src/js/reminder_topbar.js b/hr_reminder/static/src/js/reminder_topbar.js new file mode 100644 index 000000000..1db09e88c --- /dev/null +++ b/hr_reminder/static/src/js/reminder_topbar.js @@ -0,0 +1,82 @@ +odoo.define('hr_reminder.reminder_topbar', function (require) { +"use strict"; + +var core = require('web.core'); +var SystrayMenu = require('web.SystrayMenu'); +var Widget = require('web.Widget'); +var QWeb = core.qweb; +var ajax = require('web.ajax'); + +var reminder_menu = Widget.extend({ + template:'hr_reminder.reminder_menu', + + events: { + "click .dropdown-toggle": "on_click_reminder", + "click .detail-client-address-country": "reminder_active", + }, + + + on_click_reminder: function (event) { + var self = this + ajax.jsonRpc("/hr_reminder/all_reminder", 'call',{} + ).then(function(all_reminder){ + self.all_reminder = all_reminder + self.$('.o_mail_navbar_dropdown_top').html(QWeb.render('hr_reminder.reminder_menu',{ + values: self.all_reminder + })); + }) + }, + + + reminder_active: function(){ + var self = this; + var value =$("#reminder_select").val(); + ajax.jsonRpc("/hr_reminder/reminder_active", 'call',{'reminder_name':value} + ).then(function(reminder){ + self.reminder = reminder + for (var i=0;i<1;i++){ + var model = self.reminder[i] + var date = self.reminder[i+1] + console.log("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDd",date,new Date()) + if (self.reminder[i+2] == 'today'){ + + return self.do_action({ + type: 'ir.actions.act_window', + res_model: model, + view_mode: 'tree', + view_type: 'tree', + domain: [[date, '=', new Date()]], + views: [[false, 'tree']], + target: 'new',}) + } + + else if (self.reminder[i+2] == 'set_date'){ + return self.do_action({ + type: 'ir.actions.act_window', + res_model: model, + view_mode: 'tree', + view_type: 'tree', + domain: [[date, '=', self.reminder[i+3]]], + views: [[false, 'tree']], + target: 'new',}) + } + + else if (self.reminder[i+2] == 'set_period'){ + return self.do_action({ + type: 'ir.actions.act_window', + res_model: model, + view_mode: 'tree', + view_type: 'tree', + domain: [[date, '<', self.reminder[i+5]],[date, '>', self.reminder[i+4]]], + views: [[false, 'tree']], + target: 'new',}) + } + + } + + }); + }, +}); + +SystrayMenu.Items.push(reminder_menu); +}); diff --git a/hr_reminder/static/src/xml/reminder_topbar.xml b/hr_reminder/static/src/xml/reminder_topbar.xml new file mode 100644 index 000000000..4baefbf7e --- /dev/null +++ b/hr_reminder/static/src/xml/reminder_topbar.xml @@ -0,0 +1,28 @@ + + + + +
  • + + + +
  • +
    +
    \ No newline at end of file diff --git a/hr_reminder/views/hr_reminder_view.xml b/hr_reminder/views/hr_reminder_view.xml new file mode 100644 index 000000000..5660a2945 --- /dev/null +++ b/hr_reminder/views/hr_reminder_view.xml @@ -0,0 +1,76 @@ + + + + + + Reminder scheduler + + 1 + minutes + -1 + + + + + + + hr.reminder.form.view + hr.reminder + +
    + +
    +

    + +

    +
    + + + + + + + + + + + + + + + + + +
    +
    +
    +
    + + + hr.reminder.tree.view + hr.reminder + + + + + + + + + + + + Reminders + hr.reminder + tree,form + +

    + Click here to create new reminder. +

    +
    +
    + + + +
    +
    \ No newline at end of file diff --git a/hr_reminder/views/reminder_template.xml b/hr_reminder/views/reminder_template.xml new file mode 100644 index 000000000..e7cf0e20a --- /dev/null +++ b/hr_reminder/views/reminder_template.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file