diff --git a/im_notif/README.rst b/im_notif/README.rst deleted file mode 100644 index b3ef2c7..0000000 --- a/im_notif/README.rst +++ /dev/null @@ -1,13 +0,0 @@ -IM Notifications -================ - -Description: https://apps.odoo.com/apps/modules/8.0/im_notif/ - -Further information and discussion: https://yelizariev.github.io/odoo/module/2015/02/18/im-notifications.html - -Tested on Odoo 8.0 ab7b5d7732a7c222a0aea45bd173742acd47242d - -Odoo 9.0+ -========= - -For newer version the module is not needed, cause there is similar built-in feature diff --git a/im_notif/__init__.py b/im_notif/__init__.py deleted file mode 100644 index e8cfb16..0000000 --- a/im_notif/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -# -*- coding: utf-8 -*- -from . import im_notif_models - - -def pre_uninstall(cr, registry): - query = ("UPDATE res_partner " - "SET notify_email = 'always' " - "WHERE notify_email LIKE 'im%';") - cr.execute(query) diff --git a/im_notif/__openerp__.py b/im_notif/__openerp__.py deleted file mode 100644 index a4c3c5e..0000000 --- a/im_notif/__openerp__.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -{ - 'name': 'IM Notifications', - 'version': '1.0.1', - 'author': 'IT-Projects LLC, Ivan Yelizariev', - 'license': 'GPL-3', - 'category': 'Tools', - 'website': 'https://twitter.com/yelizariev', - 'price': 9.00, - 'currency': 'EUR', - 'depends': ['im_chat', 'mail'], - 'images': ['images/my-pref.png'], - 'data': [ - 'im_notif_data.xml', - 'im_notif_views.xml', - ], - 'installable': True, - 'uninstall_hook': 'pre_uninstall', -} diff --git a/im_notif/doc/changelog.rst b/im_notif/doc/changelog.rst deleted file mode 100644 index 9ae06bd..0000000 --- a/im_notif/doc/changelog.rst +++ /dev/null @@ -1,4 +0,0 @@ -`1.0.1` -------- - -- Hide Notifications user diff --git a/im_notif/im_notif_data.xml b/im_notif/im_notif_data.xml deleted file mode 100644 index fb8a164..0000000 --- a/im_notif/im_notif_data.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - Notifications - - Technical profile. You should not delete it. - - - Notifications - notifications - - - - - - - - diff --git a/im_notif/im_notif_models.py b/im_notif/im_notif_models.py deleted file mode 100644 index d12752a..0000000 --- a/im_notif/im_notif_models.py +++ /dev/null @@ -1,160 +0,0 @@ -# -*- coding: utf-8 -*- -from openerp import SUPERUSER_ID -from openerp import models -from openerp import tools -from openerp.osv import fields as old_fields - - -class ResPartner(models.Model): - _inherit = 'res.partner' - _columns = { - 'notify_email': old_fields.selection([ - ('none', 'Never'), - ('im', 'Only IM (if online)'), - ('im_xor_email', 'IM (if online) + email (if offline)'), - ('im_and_email', 'IM (if online) + email'), - ('always', 'Only emails'), - ], 'Receive Inbox Notifications by Email, IM', required=True, - oldname='notification_email_send', - help="Policy to receive emails, IM for new messages pushed to your personal Inbox. IM can be used only for partners with odoo user account" - ), - } - - -class MailNotification(models.Model): - _inherit = 'mail.notification' - - def get_recipients(self, cr, uid, ids, message, context=None): - # based on addons/mail/mail_followers.py::get_partners_to_email - """ Return the list of partners to notify, based on their preferences. - - :param browse_record message: mail.message to notify - :param list partners_to_notify: optional list of partner ids restricting - the notifications to process - """ - email_pids = [] - im_uids = [] - for notification in self.browse(cr, uid, ids, context=context): - if notification.is_read: - continue - partner = notification.partner_id - # Do not send to partners without email address defined - if not partner.email: - continue - # Do not send to partners having same email address than the author (can cause loops or bounce effect due to messy database) - if message.author_id and message.author_id.email == partner.email: - continue - # Partner does not want to receive any emails or is opt-out - n = partner.notify_email - if n == 'none': - continue - if n == 'always': - email_pids.append(partner.id) - continue - send_email = False - for user in partner.user_ids: - if user.im_status == 'offline': - if n != 'im': - send_email = True - else: - im_uids.append(user.id) - if n == 'im_and_email': - send_email = True - - if not len(partner.user_ids): - # send notification to partner, that doesn't have odoo account, but has "im*" value in notify_email - send_email = True - - if send_email: - email_pids.append(partner.id) - - return email_pids, im_uids - - def _message2im(self, cr, uid, message): - inbox_action = self.pool['ir.model.data'].xmlid_to_res_id(cr, SUPERUSER_ID, 'mail.mail_inboxfeeds') - inbox_url = '#menu_id=%s' % inbox_action - url = None - if message.res_id: - url = '#id=%s&model=%s&view_type=form' % ( - message.res_id, - message.model - ) - author = message.author_id and message.author_id.name_get() - author = author and author[0][1] or message.email_from - - about = message.subject or message.record_name or 'UNDEFINED' - about = '[ABOUT] %s' % about - if url: - about = '%s' % (url, about) - im_text = [ - '_____________________', - '_____[open_inbox]_____' % inbox_url, - '%s [FROM] %s' % (message.type, author), - about, - ] - # im_text = im_text + body.split('\n') - return im_text - - def _notify_email(self, cr, uid, ids, message_id, force_send=False, user_signature=True, context=None): - # based on addons/mail/mail_followers.py::_notify_email - message = self.pool['mail.message'].browse(cr, SUPERUSER_ID, message_id, context=context) - - # compute partners - email_pids, im_uids = self.get_recipients(cr, uid, ids, message, context=None) - if email_pids: - self._do_notify_email(cr, uid, email_pids, message, force_send, user_signature, context) - - if im_uids: - self._do_notify_im(cr, uid, im_uids, message, context) - - return True - - def _do_notify_im(self, cr, uid, im_uids, message, context=None): - im_text = self._message2im(cr, uid, message) - - user_from = self.pool['ir.model.data'].xmlid_to_res_id(cr, SUPERUSER_ID, 'im_notif.notif_user') - - session_obj = self.pool['im_chat.session'] - message_type = 'message' - for user_to in im_uids: - session = session_obj.session_get(cr, user_from, user_to, context=context) - uuid = session.get('uuid') - message_content = '\n'.join(im_text) - self.pool["im_chat.message"].post(cr, SUPERUSER_ID, user_from, uuid, message_type, message_content, context=context) - - return True - - def _do_notify_email(self, cr, uid, email_pids, message, force_send=False, user_signature=True, context=None): - - # compute email body (signature, company data) - body_html = message.body - # add user signature except for mail groups, where users are usually adding their own signatures already - user_id = message.author_id and message.author_id.user_ids and message.author_id.user_ids[0] and message.author_id.user_ids[0].id or None - signature_company = self.get_signature_footer(cr, uid, user_id, res_model=message.model, res_id=message.res_id, context=context, user_signature=(user_signature and message.model != 'mail.group')) - if signature_company: - body_html = tools.append_content_to_html(body_html, signature_company, plaintext=False, container_tag='div') - # compute email references - references = message.parent_id.message_id if message.parent_id else False - - # custom values - custom_values = dict() - if message.model and message.res_id and self.pool.get(message.model) and hasattr(self.pool[message.model], 'message_get_email_values'): - custom_values = self.pool[message.model].message_get_email_values(cr, uid, message.res_id, message, context=context) - - # create email values - max_recipients = 50 - chunks = [email_pids[x:x + max_recipients] for x in xrange(0, len(email_pids), max_recipients)] - email_ids = [] - for chunk in chunks: - mail_values = { - 'mail_message_id': message.id, - 'auto_delete': True, - 'body_html': body_html, - 'recipient_ids': [(4, id) for id in chunk], - 'references': references, - } - mail_values.update(custom_values) - email_ids.append(self.pool.get('mail.mail').create(cr, uid, mail_values, context=context)) - if force_send and len(chunks) < 2: # for more than 50 followers, use the queue system - self.pool.get('mail.mail').send(cr, uid, email_ids, context=context) - return True diff --git a/im_notif/im_notif_views.xml b/im_notif/im_notif_views.xml deleted file mode 100644 index 38ee97f..0000000 --- a/im_notif/im_notif_views.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - diff --git a/im_notif/images/my-pref.png b/im_notif/images/my-pref.png deleted file mode 100644 index a3d8616..0000000 Binary files a/im_notif/images/my-pref.png and /dev/null differ diff --git a/im_notif/static/description/icon.png b/im_notif/static/description/icon.png deleted file mode 100644 index b43a0a1..0000000 Binary files a/im_notif/static/description/icon.png and /dev/null differ diff --git a/im_notif/static/description/im-chat.png b/im_notif/static/description/im-chat.png deleted file mode 100644 index 9728b0d..0000000 Binary files a/im_notif/static/description/im-chat.png and /dev/null differ diff --git a/im_notif/static/description/index.html b/im_notif/static/description/index.html deleted file mode 100644 index c67c76d..0000000 --- a/im_notif/static/description/index.html +++ /dev/null @@ -1,69 +0,0 @@ -
-
-
-

IM Notifications

-

Get instant notification inside odoo

-
- -
-

- A user is able to select option for notifications: - -

    -
  • Never
  • -
  • Only IM (if online)
  • -
  • IM (if online) + email (if offline)
  • -
  • IM (if online) + email
  • -
  • Only Emails
-

-
- -
-
- -
-
-
-
- -
-
-
-

- Each notification includes: -

    -
  • Message type: email, comment or notification
  • -
  • Author's name
  • -
  • Subject with a link to related record (if exists)
  • -
  • Link to inbox
  • -
-

-
- -
-
- -
-
- - -
-
- -
-
- -
-
diff --git a/im_notif/static/description/my-pref-button.png b/im_notif/static/description/my-pref-button.png deleted file mode 100644 index 601e6a8..0000000 Binary files a/im_notif/static/description/my-pref-button.png and /dev/null differ diff --git a/im_notif/static/src/js/im_notif.js b/im_notif/static/src/js/im_notif.js deleted file mode 100644 index 7e2c6e5..0000000 --- a/im_notif/static/src/js/im_notif.js +++ /dev/null @@ -1,44 +0,0 @@ - (function(){ - - "use strict"; - - var _t = openerp._t; - var _lt = openerp._lt; - var QWeb = openerp.qweb; - - openerp.im_chat.Conversation.include({ - escape_keep_url: function(str){ - //var url_regex = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi; - var url_regex = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?|(]*href="([^"]*)"[^>]*>([^<]*)<\/a>)/gi; - var last = 0; - var txt = ""; - while (true) { - var result = url_regex.exec(str); - if (! result) - break; - txt += _.escape(str.slice(last, result.index)); - last = url_regex.lastIndex; - var href = ''; - var content = ''; - var is_odoo_ref = false; - if (result[8]=='' + content + ''; - } - txt += _.escape(str.slice(last, str.length)); - return txt; - }, - }); - })();