Browse Source

Port JS and controller code of asterisk_click2dial to v9

pull/88/head
Juris Malinens 9 years ago
committed by Alexis de Lattre
parent
commit
45fffd04cd
  1. 14
      asterisk_click2dial/controller.py
  2. 27
      asterisk_click2dial/static/src/js/asterisk_click2dial.js
  3. 3
      asterisk_click2dial/static/src/xml/asterisk_click2dial.xml
  4. 6
      asterisk_click2dial/web_asterisk_click2dial.xml

14
asterisk_click2dial/controller.py

@ -1,14 +1,16 @@
# -*- coding: utf-8 -*-
# © 2014-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# © 2015-2016 Juris Malinens (port to v9)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import openerp
from openerp import http
class AsteriskClick2dialController(openerp.addons.web.http.Controller):
_cp_path = '/asterisk_click2dial'
class AsteriskClick2dialController(http.Controller):
@openerp.addons.web.http.jsonrequest
def get_record_from_my_channel(self, req):
res = req.session.model('asterisk.server').get_record_from_my_channel()
@http.route(
'/asterisk_click2dial/get_record_from_my_channel/',
type='json', auth='public')
def get_record_from_my_channel(self, **kw):
res = http.request.env['asterisk.server'].get_record_from_my_channel()
return res

27
asterisk_click2dial/static/src/js/asterisk_click2dial.js

@ -1,12 +1,20 @@
/* © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
/* © 2014-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
© 2015-2016 Juris Malinens (port to v9)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
odoo.define('asterisk_click2dial.OpenCaller', function (require) {
odoo.define('asterisk_click2dial.click2dial', function (require) {
"use strict";
var _t = core._t;
var UserMenu = require('web.UserMenu');
var WebClient = require('web.WebClient');
var web_client = require('web.web_client');
var Widget = require('web.Widget');
var OpenCaller = Widget.extend({
var core = require('web.core');
var click2dial = {};
click2dial.OpenCaller = Widget.extend({
template: 'asterisk_click2dial.OpenCaller',
start: function () {
@ -36,7 +44,7 @@ var OpenCaller = Widget.extend({
target: 'new',
context: {'default_calling_number': r},
};
instance.client.action_manager.do_action(action);
web_client.action_manager.do_action(action);
}
else if (typeof r == 'object' && r.length == 3) {
@ -52,22 +60,21 @@ var OpenCaller = Widget.extend({
target: 'current',
context: {},
};
instance.client.action_manager.do_action(action);
web_client.action_manager.do_action(action);
}
});
},
});
instance.web.UserMenu.include({
UserMenu.include({
do_update: function(){
this._super.apply(this, arguments);
this.update_promise.then(function() {
var asterisk_button = new instance.web.OpenCaller();
asterisk_button.appendTo(instance.webclient.$el.find('.oe_systray'));
var asterisk_button = new click2dial.OpenCaller();
//console.log(this);
asterisk_button.appendTo($('.oe_systray'));
});
},
});
});

3
asterisk_click2dial/static/src/xml/asterisk_click2dial.xml

@ -7,13 +7,12 @@
<template>
<!-- Add phone button in top right menu for "Open Caller" -->
<!--
<t t-name="asterisk_click2dial.OpenCaller">
<li class="oe_topbar_item oe_topbar_open_caller"
title="Open Caller">
<a id="asterisk-open-caller" href="#" class="fa fa-phone"/>
</li>
</t>-->
</t>
<!-- Add Dial button in phone widget for click2dial feature -->
<t t-extend="FieldPhone">

6
asterisk_click2dial/web_asterisk_click2dial.xml

@ -4,10 +4,9 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<odoo>
<data>
<!--
<template id="assets_backend" name="asterisk_click2dial assets"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
@ -15,7 +14,6 @@
src="/asterisk_click2dial/static/src/js/asterisk_click2dial.js"></script>
</xpath>
</template>
-->
</data>
</openerp>
</odoo>
Loading…
Cancel
Save