Ver Fonte

primer commit

edgar há 8 anos atrás
commit
58b8cb8f96

+ 22 - 0
__init__.py

@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2011-today Synconics Technologies Pvt. Ltd. (<http://www.synconics.com>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

+ 40 - 0
__openerp__.py

@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2011-today Synconics Technologies Pvt. Ltd. (<http://www.synconics.com>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+    "name": "Chat Push Notification",
+    "version": "1.0",
+    "author": "Synconics Technologies Pvt. Ltd.",
+    "website": "www.synconics.com",
+    "version": "1.0",
+    "catagory": "Social Network",
+    "complexity": "easy",
+    "summary": "Odoo Chat Push Notification",
+    "description": """
+   The push notification shows at the status bar that you have received a new chat message. This notification will make you aware about the message and you can take action on it at the same moment.
+    """,
+    "depends": ["im_chat"],
+	"data": ["views/chat_notification_view.xml"],
+    "qweb": [],
+    "installable": True,
+    "auto_install": False
+}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
static/description/chat-push-notification.png


BIN
static/description/icon.png


+ 38 - 0
static/description/index.html

@@ -0,0 +1,38 @@
+<section class="oe_container">
+    <div class="oe_row oe_spaced">
+        <div class="oe_span12">
+            <h2 class="oe_slogan">Chat Push Notification</h2>
+            <h3 class="oe_slogan">The push notification shows at the status bar that you have received a new chat message. This notification will make you aware about the message and you can take action on it at the same moment.</h3>
+        </div>
+    </div>
+</section>
+<!-- Second block -->
+<section class="oe_container oe_dark">
+    <div class="oe_row oe_spaced">
+        <div class="oe_span12">
+            <div class="oe_row_img oe_centered">
+                <img class="oe_picture oe_screenshot" src="chat-push-notification.png">
+            </div>
+        </div>
+    </div>
+</section>
+<!-- Fifth block -->
+<section class="oe_container">
+    <div class="oe_row oe_spaced">
+        <div class="oe_span12">
+            <h2 class="oe_slogan">Contact / Support</h2>
+            <h3 class="oe_slogan">Need help or want extra features?</h3>
+        </div>
+	<div class="oe_span6">
+            <div class="oe_picture">
+                    <a href="http://www.synconics.com"><img src="logo.png"></a>
+            </div>
+        </div>
+	<div class="oe_span6">
+            <p class="oe_mt32">
+		Need help with the configuration or want this module to have more functionalities?
+		Contact us through e-mail at <a href="mailto:contact@synconics.com">contact@synconics.com</a>
+            </p>
+        </div>
+    </div>
+</section>

BIN
static/description/logo.png


+ 39 - 0
static/src/js/chat_notification.js

@@ -0,0 +1,39 @@
+function play_chat() {
+	var snd = new Audio("../sonido/chat.wav");
+	snd.play();
+	return false;
+};
+
+
+openerp.sync_chat_notification = function(instance) {
+	var QWeb = instance.web.qweb;
+	var _t = instance.web._t;
+
+	openerp.im_chat.ConversationManager.include({
+		received_message: function(message) {
+			var self = this;
+			this._super.apply(this, arguments);
+			if (!this.get("window_focus")) {
+				if (this.session.uid != message.from_id[0]) {
+					Notification.requestPermission(function(permission) {
+						var image_url = openerp.session.url('/web/binary/image', {
+							model: 'res.users',
+							field: 'image_small',
+							id: message.from_id[0]
+						});
+						var message_content = (typeof message.rem_html_smiley === "undefined") ? message.message : message.rem_html_smiley;
+						var notification = new Notification(message.from_id[1], {
+							body: message_content,
+							icon: image_url,
+							dir: 'auto'
+						});
+						return play_chat();
+						setTimeout(function() {
+							notification.close();
+						}, 4000);
+					});
+				}
+			}
+		}
+	});
+}

+ 10 - 0
views/chat_notification_view.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+    	<template id="assets_backend" name="web_tests assets" inherit_id="web.assets_backend">
+            <xpath expr="." position="inside">
+                <script type="text/javascript" src="/sync_chat_notification/static/src/js/chat_notification.js"></script>
+            </xpath>
+        </template>
+    </data>
+</openerp>