Browse Source

Cleanup requested by Eric Caudal.

pull/96/head
Trever L. Adams 9 years ago
parent
commit
641e40d717
  1. 100
      freeswitch_click2dial/README.rst
  2. 18
      freeswitch_click2dial/freeswitch_click2dial.py
  3. 4
      freeswitch_click2dial/freeswitch_click2dial_demo.xml
  4. 2
      freeswitch_click2dial/scripts/get_caller_name.py
  5. 3
      freeswitch_click2dial/static/src/js/freeswitch_click2dial.js

100
freeswitch_click2dial/README.rst

@ -7,50 +7,20 @@ FreeSWITCH Click2Dial
=====================
The technical name of this module is *freeswitch_click2dial*, but this module
implements much more than a simple *click2dial* ! This module adds 3
implements much more than a simple *click2dial*! This module adds 3
functionalities:
1) It adds a *Dial* button in the partner form view so that users can directly
dial a phone number through FreeSWITCH. This feature is usually known as
*click2dial*. Here is how it works :
* In Odoo, the user clicks on the *Dial* button next to a phone number
field in the partner view.
* Odoo connects to the FreeSWITCH Event Socket and FreeSWITCH makes the
user's phone ring.
* The user answers his own phone (if he doesn't, the process stops here).
* FreeSWITCH dials the phone number found in Odoo in place of the user.
* If the remote party answers, the user can talk to his correspondent.
*click2dial*.
2) It adds the ability to show the name of the calling party on the screen of
your IP phone on incoming phone calls if the presented phone number is
present in the partner/leads/employees/... of Odoo. To understand how to
use this, please see get_caller_name.py, which should be installed per the
instructions in the script on the Odoo/Odoo server. This works for
incoming and outgoing calls, per instructions in the script.
present in the partner/leads/employees/... of Odoo.
3) It adds a phone icon (*Open Caller*) in the top menu bar
(next to the Preferences) to get the partner/lead/candidate/registrations
corresponding to the calling party in one click. Here is how it works :
* When the user clicks on the phone icon, Odoo sends a query to the
FreeSWITCH Manager Interface to get a list of the current phone calls
* If it finds a phone call involving the user's phone, it gets the phone
number of the calling party
* It searches the phone number of the calling party in the
Partners/Leads/Candidates/Registrations of Odoo. If a record matches,
it takes you to the form view of this record. If no record matchs, it
opens a wizard which proposes to create a new Partner with the presented
phone number as *Phone* or *Mobile* number or update an existing Partner.
It is possible to get a pop-up of the record corresponding to the calling
party without any action from the user via the module *base_phone_popup*.
corresponding to the calling party in one click.
Installation
============
@ -75,9 +45,9 @@ Configuration
To configure this module, you need to:
* Settings > Technical > FreeSWITCH Servers
* Setup you server
* Configure users under Settings > Users > $USER > Telphony tab
* Settings > Technical > FreeSWITCH Servers.
* Setup you server.
* Configure users under Settings > Users > $USER > Telephony tab.
Usage
=====
@ -86,14 +56,43 @@ To use this module, you need to:
* See scripts/get_caller_name.py to see how to set caller and callee name
* Click on Dial next to any phone number covered by associated modules
* Click on Dial next to any phone number covered by associated modules.
1) *click2dial*. Here is how it works :
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/{repo_id}/{branch}
* In Odoo, the user clicks on the *Dial* button next to a phone number
field in the partner view.
* Odoo connects to the FreeSWITCH Event Socket and FreeSWITCH makes the
user's phone ring.
* The user answers his own phone (if he doesn't, the process stops here).
* FreeSWITCH dials the phone number found in Odoo in place of the user.
* If the remote party answers, the user can talk to his correspondent.
2) Using Odoo to provide Caller ID Name in FreeSWITCH. To understand how to
use this, please see get_caller_name.py, which should be installed per the
instructions in the script on the Odoo/Odoo server. This works for
incoming and outgoing calls, per instructions in the script.
.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
.. branch is "8.0" for example
3) *Open Caller* Here is how it works :
* When the user clicks on the phone icon, Odoo sends a query to the
FreeSWITCH Manager Interface to get a list of the current phone calls
* If it finds a phone call involving the user's phone, it gets the phone
number of the calling party
* It searches the phone number of the calling party in the
Partners/Leads/Candidates/Registrations of Odoo. If a record matches,
it takes you to the form view of this record. If no record matchs, it
opens a wizard which proposes to create a new Partner with the presented
phone number as *Phone* or *Mobile* number or update an existing Partner.
It is possible to get a pop-up of the record corresponding to the calling
party without any action from the user via the module *base_phone_popup*.
Known issues / Roadmap
======================
@ -103,14 +102,10 @@ Known issues / Roadmap
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/
{project_repo}/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here <https://github.com/OCA/
{project_repo}/issues/new?body=module:%20
{module_name}%0Aversion:%20
{version}%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/connector-telephony/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.
Credits
=======
@ -118,8 +113,7 @@ Credits
Contributors
------------
* Firstname Lastname <email.address@example.org>
* Second Person <second.person@example.org>
* Trever L. Adams
Maintainer
----------

18
freeswitch_click2dial/freeswitch_click2dial.py

@ -7,12 +7,10 @@
from openerp import models, fields, api, _
from openerp.exceptions import UserError, ValidationError
import logging
# from pprint import pformat
try:
from freeswitchESL import ESL
except ImportError:
import ESL
# import sys
import StringIO
import re
import json
@ -43,7 +41,7 @@ class FreeSWITCHServer(models.Model):
"leave empty.")
password = fields.Char(
string='Event Socket Password', required=True,
help="Password that OpenERP will use to communicate with the "
help="Password that OpenERP/Odoo will use to communicate with the "
"FreeSWITCH Event Socket. Refer to "
"/etc/freeswitch/autoload_configs/event_socket.conf.xml "
"on your FreeSWITCH server.")
@ -120,7 +118,7 @@ class FreeSWITCHServer(models.Model):
# We check if the current user has an internal number
if not user.resource:
raise UserError(
_('No resource name configured for the current user'))
_('No resource name configured for the current user.'))
_logger.debug(
"User's phone: %s/%s", user.freeswitch_chan_type, user.resource)
@ -140,8 +138,6 @@ class FreeSWITCHServer(models.Model):
raise UserError(
_("Problem in the request from Odoo to FreeSWITCH. "
"Here is the error message: %s" % e))
# return (False, False, False)
return (user, fs_server, fs_manager)
@api.multi
@ -160,7 +156,7 @@ class FreeSWITCHServer(models.Model):
if fs_manager.connected() is not 1:
raise UserError(
_("Connection Test Failed! Check Host, Port and "
"Password"))
"Password."))
else:
fs_manager.disconnect()
except Exception, e:
@ -177,8 +173,6 @@ class FreeSWITCHServer(models.Model):
is_fq_res = user.resource.rfind('@')
if is_fq_res > 0:
resource = user.resource[0:is_fq_res]
_logger.error("is_fq_res: %d, resource is %s\n",
is_fq_res, resource)
else:
resource = user.resource
request = "channels like /" + re.sub(r'/', r':', resource) + \
@ -311,7 +305,7 @@ class ResUsers(models.Model):
except UnicodeEncodeError:
raise ValidationError(_(
"The '%s' for the user '%s' should only have "
"ASCII caracters"),
"ASCII caracters."),
check_string[0], user.name)
@api.multi
@ -342,7 +336,7 @@ class PhoneCommon(models.AbstractModel):
def click2dial(self, erp_number):
res = super(PhoneCommon, self).click2dial(erp_number)
if not erp_number:
raise UserError(_('Missing phone number'))
raise UserError(_('Missing phone number.'))
user, fs_server, fs_manager = \
self.env['freeswitch.server']._connect_to_freeswitch()
@ -355,7 +349,7 @@ class PhoneCommon(models.AbstractModel):
# The user should have a CallerID
if not user.callerid:
raise UserError(_('No callerID configured for the current user'))
raise UserError(_('No callerID configured for the current user.'))
variable = ""
if user.freeswitch_chan_type == 'user':

4
freeswitch_click2dial/freeswitch_click2dial_demo.xml

@ -9,8 +9,8 @@
<data noupdate="1">
<record id="demo_fs_server" model="freeswitch.server">
<field name="name">Akretion FreeSWITCH Server</field>
<field name="ip_address">freeswitch.akretion.com</field>
<field name="name">Company FreeSWITCH Server</field>
<field name="ip_address">freeswitch.example.com</field>
<field name="port">8021</field>
<field name="password">mypassword</field>
<field name="context">from-internal</field>

2
freeswitch_click2dial/scripts/get_caller_name.py

@ -144,8 +144,6 @@ def convert_to_ascii(my_unicode):
def main(name, phone_number, options):
# print 'options = %s' % options
# If we already have a "True" caller ID name
# i.e. not just digits, but a real name, then we don't try to
# connect to OpenERP or geoloc, we just keep it

3
freeswitch_click2dial/static/src/js/freeswitch_click2dial.js

@ -27,9 +27,6 @@ click2dial.OpenCaller = Widget.extend({
event.stopPropagation();
var self = this;
self.rpc('/freeswitch_click2dial/get_record_from_my_channel', {}).done(function(r) {
// console.log('RESULT RPC r='+r);
// console.log('RESULT RPC type r='+typeof r);
// console.log('RESULT RPC isNaN r='+isNaN(r));
if (r === false) {
self.do_warn(
_t('Failure'),

Loading…
Cancel
Save