Browse Source

Add base_phone_popup

pull/177/head
andre 6 years ago
parent
commit
ddb38ce567
  1. 3
      base_phone_popup/__init__.py
  2. 39
      base_phone_popup/__manifest__.py
  3. 3
      base_phone_popup/models/__init__.py
  4. 21
      base_phone_popup/models/phone_common.py
  5. BIN
      base_phone_popup/static/description/icon.png
  6. 40
      base_phone_popup/static/src/js/request.js
  7. 12
      base_phone_popup/static/src/xml/BasePhonePopup.xml
  8. 0
      base_phone_popup/views/res_users.xml
  9. 10
      base_phone_popup/views/template.xml

3
base_phone_popup/__init__.py

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from . import popup
from . import models

39
base_phone_popup/__manifest__.py

@ -1,43 +1,26 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2014-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# © 2014-2019 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) & K (Vladimir Andreyev hoka.spb@gmail.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
'name': 'Base Phone Pop-up', 'name': 'Base Phone Pop-up',
'version': '9.0.1.0.0',
'version': '11.0.1.0.0',
'category': 'Phone', 'category': 'Phone',
'license': 'AGPL-3', 'license': 'AGPL-3',
'summary': 'Pop-up the related form view to the user on incoming calls', 'summary': 'Pop-up the related form view to the user on incoming calls',
'description': """ 'description': """
Base Phone Pop-up 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 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/', '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,
} }

3
base_phone_popup/models/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import phone_common

21
base_phone_popup/popup.py → base_phone_popup/models/phone_common.py

@ -1,14 +1,12 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2014-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# © 2014-2019 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) & K
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # 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 import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class PhoneCommon(models.AbstractModel): class PhoneCommon(models.AbstractModel):
_inherit = 'phone.common' _inherit = 'phone.common'
@ -39,31 +37,28 @@ class PhoneCommon(models.AbstractModel):
return action return action
@api.model @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' assert isinstance(login_list, list), 'login_list must be a list'
res = self.get_record_from_phone_number(number) res = self.get_record_from_phone_number(number)
users = self.env['res.users'].search( users = self.env['res.users'].search(
[('login', 'in', login_list)]) [('login', 'in', login_list)])
logger.debug( logger.debug(
'Notify incoming call from number %s to users %s'
'-----> Notify incoming call from number %s to users %s'
% (number, users.ids)) % (number, users.ids))
action = self._prepare_incall_pop_action(res, number) action = self._prepare_incall_pop_action(res, number)
if action: if action:
for user in users: for user in users:
if user.context_incall_popup: 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: if res:
callerid = res[2] callerid = res[2]
else: else:
callerid = False callerid = False
return callerid return callerid
class ResUsers(models.Model): class ResUsers(models.Model):
_inherit = 'res.users' _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)

BIN
base_phone_popup/static/description/icon.png

After

Width: 64  |  Height: 64  |  Size: 1.7 KiB

40
base_phone_popup/static/src/js/request.js

@ -0,0 +1,40 @@
odoo.define('base_phone_popup', function (require) {
'use strict';
var core = require('web.core');
var web_client = require('web.WebClient');
var Widget = require('web.Widget');
var bus = require('bus.bus').bus;
// var session = require('web.session');
var base_phone_popup = odoo.base_phone_popup = {};
base_phone_popup.Request = Widget.extend({
init: function(parent, user_id) {
var self = this;
this._super(parent);
this.uid = this.getSession().uid
this.bus = bus;
this.channel = 'bpp_' + this.uid;
this.bus.add_channel(this.channel);
this.bus.on("notification", this, this.on_notification);
this.bus.start_polling();
console.log('Request.init channel -> ' + 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);
},
});
});

12
base_phone_popup/static/src/xml/BasePhonePopup.xml

@ -0,0 +1,12 @@
<t t-name="BasePhonePopup" >
<div id="act_req_id">
<div class="ex_button">
<div class="cancle_btn">
<button class="btn btn-danger">Cancle</button>
</div>
<div class="Add_btn">
<button class="btn btn-success">Add </button>
</div>
</div>
</div>
</t>

0
base_phone_popup/res_users_view.xml → base_phone_popup/views/res_users.xml

10
base_phone_popup/views/template.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<template id="assets_backend" name="base_phone_popup assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/base_phone_popup/static/src/js/request.js"/>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save