From ddb38ce56766042bca6c09738884b68610780ad7 Mon Sep 17 00:00:00 2001 From: andre Date: Mon, 18 Feb 2019 02:34:10 +0300 Subject: [PATCH] Add base_phone_popup --- base_phone_popup/__init__.py | 3 +- base_phone_popup/__manifest__.py | 39 +++++------------ base_phone_popup/models/__init__.py | 3 ++ .../{popup.py => models/phone_common.py} | 21 ++++----- base_phone_popup/static/description/icon.png | Bin 0 -> 1780 bytes base_phone_popup/static/src/js/request.js | 40 ++++++++++++++++++ .../static/src/xml/BasePhonePopup.xml | 12 ++++++ .../res_users.xml} | 0 base_phone_popup/views/template.xml | 10 +++++ 9 files changed, 86 insertions(+), 42 deletions(-) create mode 100644 base_phone_popup/models/__init__.py rename base_phone_popup/{popup.py => models/phone_common.py} (73%) create mode 100644 base_phone_popup/static/description/icon.png create mode 100644 base_phone_popup/static/src/js/request.js create mode 100644 base_phone_popup/static/src/xml/BasePhonePopup.xml rename base_phone_popup/{res_users_view.xml => views/res_users.xml} (100%) create mode 100644 base_phone_popup/views/template.xml diff --git a/base_phone_popup/__init__.py b/base_phone_popup/__init__.py index d5a89e7..77bbdbd 100644 --- a/base_phone_popup/__init__.py +++ b/base_phone_popup/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- -from . import popup +from . import models + diff --git a/base_phone_popup/__manifest__.py b/base_phone_popup/__manifest__.py index e56e04c..29f7ada 100644 --- a/base_phone_popup/__manifest__.py +++ b/base_phone_popup/__manifest__.py @@ -1,43 +1,26 @@ # -*- coding: utf-8 -*- -# © 2014-2016 Akretion (Alexis de Lattre ) +# © 2014-2019 Akretion (Alexis de Lattre ) & K (Vladimir Andreyev hoka.spb@gmail.com) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - { 'name': 'Base Phone Pop-up', - 'version': '9.0.1.0.0', + 'version': '11.0.1.0.0', 'category': 'Phone', 'license': 'AGPL-3', 'summary': 'Pop-up the related form view to the user on incoming calls', 'description': """ Base Phone Pop-up ================= - -When the user receives a phone call, OpenERP can automatically open the -corresponding partner/lead/employee/... in a pop-up without any action from the -user. - -The module *web_action_request* can be downloaded with Mercurial: - -hg clone http://bitbucket.org/anybox/web_action_request - -It depends on 2 other modules, *web_longpolling* and *web_socketio*, that can -be downloaded with this command: - -hg clone http://bitbucket.org/anybox/web_socketio - -You will find some hints in this documentation : -https://bitbucket.org/anybox/web_action_request - -Warning : proxying WebSockets is only supported since Nginx 1.3.13 ; the -feature provided by this module won't work with older versions of Nginx. - -TODO : document this new feature on the Akretion Web site : +When the user receives a phone call, OpenERP can automatically open the corresponding partner/lead/employee/... +in a pop-up without any action from the user. http://www.akretion.com/products-and-services/openerp-asterisk-voip-connector """, - 'author': "Akretion,Odoo Community Association (OCA)", + 'author': "Akretion,Odoo Community Association (OCA) & K", 'website': 'http://www.akretion.com/', - 'depends': ['base_phone', 'web_action_request'], - 'data': ['res_users_view.xml'], - 'installable': False, + 'depends': ['base_phone'], + 'data': [ + 'views/res_users.xml', + 'views/template.xml', + ], + 'installable': True, } diff --git a/base_phone_popup/models/__init__.py b/base_phone_popup/models/__init__.py new file mode 100644 index 0000000..08f0b66 --- /dev/null +++ b/base_phone_popup/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import phone_common diff --git a/base_phone_popup/popup.py b/base_phone_popup/models/phone_common.py similarity index 73% rename from base_phone_popup/popup.py rename to base_phone_popup/models/phone_common.py index b0fc561..c220e5b 100644 --- a/base_phone_popup/popup.py +++ b/base_phone_popup/models/phone_common.py @@ -1,14 +1,12 @@ # -*- coding: utf-8 -*- -# © 2014-2016 Akretion (Alexis de Lattre ) +# © 2014-2019 Akretion (Alexis de Lattre ) & K # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields, api, _ +from odoo import models, fields, api, _ import logging - logger = logging.getLogger(__name__) - class PhoneCommon(models.AbstractModel): _inherit = 'phone.common' @@ -39,31 +37,28 @@ class PhoneCommon(models.AbstractModel): return action @api.model - def incall_notify_by_login(self, number, login_list): + def incall_notify_by_login(self, uid, number, login_list): assert isinstance(login_list, list), 'login_list must be a list' res = self.get_record_from_phone_number(number) users = self.env['res.users'].search( [('login', 'in', login_list)]) logger.debug( - 'Notify incoming call from number %s to users %s' + '-----> Notify incoming call from number %s to users %s' % (number, users.ids)) action = self._prepare_incall_pop_action(res, number) if action: for user in users: if user.context_incall_popup: - self.sudo(user.id).env['action.request'].notify(action) - logger.debug( - 'This action has been sent to user ID %d: %s' - % (user.id, action)) +# self.sudo(user.id).env['action.request'].notify(action) + self.env['bus.bus'].sendone('%s_%d' % ("bpp", user.id), action) + logger.debug('-----> user ID %d action : %s send by bus channel %s_%d' % (user.id, action, "bpp", user.id)) if res: callerid = res[2] else: callerid = False return callerid - class ResUsers(models.Model): _inherit = 'res.users' - context_incall_popup = fields.Boolean( - string='Pop-up on Incoming Calls', default=True) + context_incall_popup = fields.Boolean(string='Pop-up on Incoming Calls', default=True) diff --git a/base_phone_popup/static/description/icon.png b/base_phone_popup/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..b26d34b5d1613474e5f96c30dc00ab0daf49d7a8 GIT binary patch literal 1780 zcmVUl>s;8-|sH&`~tF5Z6uB)!F zt+2ALv9qtTw6U|bvb46dwYRjkxV5*rwz#^txx2W!yt%x-yS=}>zQMh~!oI=7zrw`9 z!^OhH#>2(O#Ky?Q$H~UX%E!se$jZ#g%g)Np&&$rx%+Jxz(bLe<)X~$`($v<|)z{S6 z+Sb|I*V^3K+uhpS-rLviOw{m1+3!Tt@J-n7P1o;M-r(KY@J`t9SKr~@+3{G|@nGQM z-{A3C-|=DLE`0}iRkL*<@JN(^@`{8k>U1{>Fem|^^)rB>FM^9==PcG?&|IKq38Ia?eFXC z_o?pi?eO-m?f9zi@$T{Wu-n(o^6&8YxbFDA@$>NU`MK}^!Weu{Qvv@|NM^h8KeLJ010qNS#tmY2TK3|2TK85 zpHj{M000McNliru-2@p3I|=ca9iRXJ1jR{2K~z}7#h2?-T1OPX7h0(`k=*P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zXtPE`U#niT$2#oC2^m=~>GkZj*IhbW3Z{i=S5S! zx6d_?VzDLFqhH5jv6T2@`(-M*_N?6cGjLc;#WRKaalaHO`?Mp;BJE$kvxwv41O5Xe WmsZ|ht#{A>0000 ' + this.channel); + }, + on_notification: function(notification) { + var self = this; + var channel = notification[0][0]; + var action = notification[0][1]; + console.log("channel -> " + JSON.stringify(channel) + " action -> " + JSON.stringify(action)); + if (channel == this.channel) { + this.do_action(action); + } + }, + }); + web_client.include({ + show_application: function() { + this._super(); + console.log(" Show_application uid -> " + this.getSession().uid); + this.base_phone_popup = new base_phone_popup.Request(this, this.getSession().uid); + }, + }); +}); diff --git a/base_phone_popup/static/src/xml/BasePhonePopup.xml b/base_phone_popup/static/src/xml/BasePhonePopup.xml new file mode 100644 index 0000000..9391fd4 --- /dev/null +++ b/base_phone_popup/static/src/xml/BasePhonePopup.xml @@ -0,0 +1,12 @@ + +
+
+
+ +
+
+ +
+
+
+
diff --git a/base_phone_popup/res_users_view.xml b/base_phone_popup/views/res_users.xml similarity index 100% rename from base_phone_popup/res_users_view.xml rename to base_phone_popup/views/res_users.xml diff --git a/base_phone_popup/views/template.xml b/base_phone_popup/views/template.xml new file mode 100644 index 0000000..0a19227 --- /dev/null +++ b/base_phone_popup/views/template.xml @@ -0,0 +1,10 @@ + + + +