Skip to content

Commit

Permalink
Merge a09a0d2 into 8dfb798
Browse files Browse the repository at this point in the history
  • Loading branch information
treveradams committed Sep 3, 2017
2 parents 8dfb798 + a09a0d2 commit 9b8209f
Show file tree
Hide file tree
Showing 45 changed files with 4,954 additions and 142 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -31,7 +31,7 @@ install:
- git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- travis_install_nightly
- pip install phonenumbers py-Asterisk SOAPpy
- pip install phonenumbers py-Asterisk SOAPpy FreeSWITCH-ESL-Python
- hg clone http://bitbucket.org/anybox/web_action_request -b ${VERSION} ${HOME}/web_action_request
- if [ -d /home/travis/${ODOO_REPO##*/}-${VERSION}/addons ]; then ln -s ${HOME}/web_action_request/web_action_request /home/travis/${ODOO_REPO##*/}-${VERSION}/addons; fi
- hg clone http://bitbucket.org/anybox/bus_enhanced -b ${VERSION} ${HOME}/bus_enhanced
Expand Down
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -3,7 +3,7 @@

# Odoo telephony connector

This projets aims at connecting Odoo to different phone systems. Phone systems currently supported are Asterisk (an OpenSource IPBX, cf [asterisk.org](http://www.asterisk.org/) and OVH (the centrex offer of OVH, cf the [OVH website](http://www.ovhtelecom.fr/telephonie/)).
This projets aims at connecting Odoo to different phone systems. Phone systems currently supported are Asterisk (an OpenSource IPBX, cf [asterisk.org](http://www.asterisk.org/), OVH (the centrex offer of OVH, cf the [OVH website](http://www.ovhtelecom.fr/telephonie/)) and FreeSWITCH (cross-platform multi-protocol soft switch, cf [FreeSWITCH.org](http://freeswitch.org)).

This project provides:
* a serie of modules (base\_phone, base\_phone\_popup,
Expand All @@ -30,6 +30,7 @@ addon | version | summary
[base_phone_popup](base_phone_popup/) | 9.0.1.0.0 | Pop-up the related form view to the user on incoming calls
[crm_phone](crm_phone/) | 9.0.1.0.0 | Validate phone numbers in CRM
[event_phone](event_phone/) | 9.0.1.0.0 | Validate phone numbers in Events
[freeswitch_click2dial](freeswitch_click2dial/) | 9.0.1.0.0 | FreeSWITCH-Odoo telephony connector (click2dial)
[hr_phone](hr_phone/) | 9.0.1.0.0 | Validate phone numbers in HR
[hr_recruitment_phone](hr_recruitment_phone/) | 9.0.1.0.0 | Validate phone numbers in HR Recruitment

Expand Down
144 changes: 144 additions & 0 deletions asterisk_click2dial/README.rst
@@ -0,0 +1,144 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

=======================
Asterisk-Odoo connector
=======================

The technical name of this module is *asterisk_click2dial*, but this module
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 Asterisk. This feature is usually known as
*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.

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.

Installation
============

To install this module, you need to:

* Click on the module and install it

Configuration
=============

To configure this module, you need to:

* Settings > Technical > Asterisk Servers.
* Setup you server.
* Configure users under Settings > Users > $USER > Telephony tab.

Usage
=====

To use this module, you need to:

* See scripts/* (as mentioned below in section 2 of Usage) to see how to set
caller and callee name.

* Click on Dial next to any phone number covered by associated modules.

1) *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 Asterisk Manager Interface and Asterisk makes the
user's phone ring.

* The user answers his own phone (if he doesn't, the process stops here).

* Asterisk 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 Asterisk. To understand how to
use this, please see the scripts mentioned below, 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.


* On incoming phone calls, the Asterisk dialplan executes an AGI script
"set_name_incoming_timeout.sh".

* The "set_name_incoming_timeout.sh" script calls the "set_name_agi.py"
script with a short timeout.

* The "set_name_agi.py" script will make an XML-RPC request on the Odoo
server to try to find the name of the person corresponding to the phone
number presented by the calling party.

* If it finds the name, it is set as the CallerID name of the call, so as
to be presented on the IP phone of the user.

It also works on outgoing calls, so as to display the name of the callee on
the SIP phone of the caller. For that, you should use the script
"set_name_outgoing_timeout.sh".

3) *Open Caller* Here is how it works :

* When the user clicks on the phone icon, Odoo sends a query to the
Asterisk 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*.

A detailed documentation for this module is available on the Akretion Web site:
http://www.akretion.com/products-and-services/openerp-asterisk-voip-connector

Known issues / Roadmap
======================

* None

Bug Tracker
===========

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
=======

Contributors
------------

* Akretion
* Odoo Community Association (OCA)

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit http://odoo-community.org.

67 changes: 0 additions & 67 deletions asterisk_click2dial/__openerp__.py
Expand Up @@ -8,73 +8,6 @@
'category': 'Phone',
'license': 'AGPL-3',
'summary': 'Asterisk-Odoo connector',
'description': """
Asterisk-Odoo connector
==========================
The technical name of this module is *asterisk_click2dial*, but this module
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 Asterisk. 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 Asterisk Manager Interface and Asterisk makes the
user's phone ring.
* The user answers his own phone (if he doesn't, the process stops here).
* Asterisk 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) 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. Here is how it works:
* On incoming phone calls, the Asterisk dialplan executes an AGI script
"set_name_incoming_timeout.sh".
* The "set_name_incoming_timeout.sh" script calls the "set_name_agi.py"
script with a short timeout.
* The "set_name_agi.py" script will make an XML-RPC request on the Odoo
server to try to find the name of the person corresponding to the phone
number presented by the calling party.
* If it finds the name, it is set as the CallerID name of the call, so as
to be presented on the IP phone of the user.
It also works on outgoing calls, so as to display the name of the callee on
the SIP phone of the caller. For that, you should use the script
"set_name_outgoing_timeout.sh".
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
Asterisk 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*.
A detailed documentation for this module is available on the Akretion Web site:
http://www.akretion.com/products-and-services/openerp-asterisk-voip-connector
""",
'author': "Akretion,Odoo Community Association (OCA)",
'website': 'http://www.akretion.com/',
'depends': ['base_phone'],
Expand Down
10 changes: 5 additions & 5 deletions asterisk_click2dial/asterisk_click2dial.py
Expand Up @@ -76,11 +76,11 @@ class AsteriskServer(models.Model):
'context', 'alert_info', 'login', 'password')
def _check_validity(self):
for server in self:
out_prefix = ('Out prefix', server.out_prefix)
dialplan_context = ('Dialplan context', server.context)
alert_info = ('Alert-Info SIP header', server.alert_info)
login = ('AMI login', server.login)
password = ('AMI password', server.password)
out_prefix = (_('Out prefix'), server.out_prefix)
dialplan_context = (_('Dialplan context'), server.context)
alert_info = (_('Alert-Info SIP header'), server.alert_info)
login = (_('AMI login'), server.login)
password = (_('AMI password'), server.password)

if out_prefix[1] and not out_prefix[1].isdigit():
raise ValidationError(
Expand Down
1 change: 1 addition & 0 deletions asterisk_click2dial/scripts/set_name_agi.py
Expand Up @@ -387,6 +387,7 @@ def main(options, arguments):
stdout_write('SET CALLERID "%s"<%s>\n' % (res, phone_number))
return True


if __name__ == '__main__':
usage = "Usage: get_name_agi.py [options] login1 login2 login3 ..."
epilog = "Script written by Alexis de Lattre. "
Expand Down
20 changes: 9 additions & 11 deletions asterisk_click2dial/static/src/js/asterisk_click2dial.js
Expand Up @@ -35,28 +35,26 @@ click2dial.OpenCaller = Widget.extend({
_t('Failure'),
_t('Problem in the connection to Asterisk'),
false);
}
else if (typeof r == 'string' && isNaN(r)) {
} else if (typeof r == 'string' && isNaN(r)) {
self.do_warn(
r,
_t('The calling number is not a phone number!'),
false);
}
else if (typeof r == 'string') {
} else if (typeof r == 'string') {
var action = {
name: _t('Number Not Found'),
type: 'ir.actions.act_window',
res_model: 'number.not.found',
view_mode: 'form',
views: [[false, 'form']],
target: 'new',
context: {'default_calling_number': r},
context: {'default_calling_number': r}
};
web_client.action_manager.do_action(action);

}
else if (typeof r == 'object' && r.length == 3) {
self.do_notify( // Not working
} else if (typeof r == 'object' && r.length == 3) {
// self.do_notify Not working
self.do_notify(
_t('Success'),
_t('Moving to %s ID %d', r[0], r[1]),
false);
Expand All @@ -74,12 +72,12 @@ click2dial.OpenCaller = Widget.extend({
If you want to use target: 'current', with web/enterprise,
you have to reload the Web page just after */
target: 'current',
context: {},
context: {}
};
web_client.action_manager.do_action(action);
}
});
},
}
});

UserMenu.include({
Expand All @@ -90,7 +88,7 @@ click2dial.OpenCaller = Widget.extend({
// attach the phone logo/button to the systray
asterisk_button.appendTo($('.oe_systray'));
});
},
}
});

});
8 changes: 7 additions & 1 deletion base_phone/fields.py
Expand Up @@ -7,11 +7,15 @@

from openerp import api, fields, models
from operator import attrgetter
import phonenumbers
import logging

_logger = logging.getLogger(__name__)

try:
import phonenumbers
except (ImportError, IOError) as err:
_logger.debug(err)


class Phone(fields.Char):

Expand Down Expand Up @@ -108,6 +112,7 @@ def get_phone_fields(self, vals):
fields_to_convert.append(key)
return fields_to_convert


original_write = models.BaseModel.write
original_create = models.BaseModel.create

Expand All @@ -133,5 +138,6 @@ def create(self, vals):
vals = convert_all_phone_fields(self, vals, fields_to_convert)
return original_create(self, vals)


models.BaseModel.write = write
models.BaseModel.create = create
10 changes: 7 additions & 3 deletions base_phone/models/phone_common.py
Expand Up @@ -3,13 +3,17 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models, api
from openerp.addons.base_phone.fields import Phone
from ..fields import Phone
import logging
# Lib for phone number reformating -> pip install phonenumbers
import phonenumbers

_logger = logging.getLogger(__name__)

# Lib for phone number reformating -> pip install phonenumbers
try:
import phonenumbers
except (ImportError, IOError) as err:
_logger.debug(err)


class PhoneCommon(models.AbstractModel):
_name = 'phone.common'
Expand Down
2 changes: 1 addition & 1 deletion base_phone/models/res_partner.py
Expand Up @@ -4,7 +4,7 @@


from openerp import models, api
from openerp.addons.base_phone import fields
from .. import fields


class ResPartner(models.Model):
Expand Down

0 comments on commit 9b8209f

Please sign in to comment.