edgar 8 anni fa
commit
b2e93d6ff3

+ 24 - 0
__init__.py

@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-today OpenERP SA (<http://www.openerp.com>)
+#    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/>.
+#
+##############################################################################
+import mail
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
__init__.pyc


+ 41 - 0
__openerp__.py

@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-today OpenERP SA (<http://www.openerp.com>)
+#    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": "Mail Push Notification",
+    "version": "1.0",
+    "author": "Synconics Technologies Pvt. Ltd. and Modificado por Edgar Ortigoza",
+    "website": "www.synconics.com",
+    "version": "1.0",
+    "catagory": "Social Network",
+    "complexity": "easy",
+    "summary": "Odoo Mail Push Notification",
+    "description": """
+   The push notification shows at the status bar that you have received a new mail message. This notification will make you aware about the message and you can take action on it at the same moment.
+    """,
+    "depends": ["mail"],
+	"data": ["views/mail_notification_view.xml"],
+    "qweb": [],
+    "installable": True,
+    "auto_install": False
+}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

+ 65 - 0
mail.py

@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-today OpenERP SA (<http://www.openerp.com>)
+#    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/>.
+#
+##############################################################################
+
+import datetime
+from openerp import SUPERUSER_ID, api
+from openerp.osv import osv, orm, fields
+
+class mail_notification(osv.Model):
+    _inherit = 'mail.notification'
+
+    _columns = {
+        'is_notified': fields.boolean('Notified')
+    }
+
+    _defaults = {
+        'is_notified': False
+    }
+
+    #------------------------------------------------------
+    # Notification 
+    #------------------------------------------------------
+    @api.cr_uid_ids_context
+    def get_message_notification(self, cr, uid, context=None):
+        notification_data = {}
+        message_obj = self.pool.get('mail.message')
+        current_date = datetime.datetime.utcnow()
+        delta = datetime.timedelta(minutes=5)
+        before_time = (current_date - delta).strftime("%Y-%m-%d %H:%M:%S")
+        msg_ids = message_obj.search(cr, uid, [('date', '>=', before_time), ('date', '<', current_date.strftime("%Y-%m-%d %H:%M:%S"))], context=context)
+        if msg_ids:
+            user_id = self.pool['res.users'].browse(cr, SUPERUSER_ID, uid, context=context)
+            domain = [('partner_id', '=', user_id.partner_id and user_id.partner_id.id), ('message_id', 'in', msg_ids), ('is_read', '=', False), ('is_notified', '=', False)]
+            notif_ids = self.search(cr, uid, domain, context=context) or False
+            for notif_id in self.browse(cr, uid, notif_ids, context=context):
+                message_id = message_obj.browse(cr, uid, notif_id.message_id and notif_id.message_id.id or False, context=context)
+                notification_data[notif_id.id] = {
+                    'id': notif_id.id,
+                    'email_from': message_id.email_from.split('<')[0],
+                    'subject': message_id.subject or '-- No Subject --',
+                    'company_id': user_id.company_id.id or False
+                }
+            return notification_data or {}
+        return {}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+

BIN
mail.pyc


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">Mail Push Notification</h2>
+            <h3 class="oe_slogan">The push notification shows at the status bar that you have received a new mail 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="mail-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


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


+ 1 - 0
static/src/js/mail_notification.js

@@ -0,0 +1 @@
+function play_sonido(){return new Audio("/sync_mail_notification/static/src/sonido/bip_1.wav").play(),!1}openerp.sync_mail_notification=function(i){i.web.qweb,i.web._t,i.mail.Widget.include({init:function(n,o){this._super.apply(this,arguments);var t=new i.web.CompoundContext,e=new i.web.DataSet(this,"mail.notification",t);this.auto_refresh(t,e)},auto_refresh:function(i,n){setInterval(function(){n.call("get_message_notification",[]).done(function(i){_.each(i,function(i){var o=openerp.session.url("/web/binary/image",{model:"res.company",field:"logo",id:i.company_id});n.call("write",[i.id,{is_notified:!0}]).then(function(i){}),Notification.requestPermission(function(n){return new Notification(i.email_from,{body:i.subject,icon:o,dir:"auto"}),play_sonido()})})})},6e4)}})};

BIN
static/src/sonido/bip_1.wav


BIN
static/src/sonido/email.wav


+ 10 - 0
views/mail_notification_view.xml

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