Skip to content

Commit

Permalink
[MIG] Phone icon funcionality in the top menu bar
Browse files Browse the repository at this point in the history
  • Loading branch information
luisDIXMIT committed Apr 8, 2024
1 parent a8eb281 commit 004ddf6
Show file tree
Hide file tree
Showing 9 changed files with 366 additions and 20 deletions.
81 changes: 81 additions & 0 deletions asterisk_click2dial/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,87 @@ of Akretion's Web site.
.. contents::
:local:

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

To configure this module, you need to:

#. Go to the user data, go to "Telephony" page and set "Resource Name"
with the name you want(can be the same as Internal Number when channel
type is SIP) and "Internal Number" with the user's phone number. Also
check that the asterisk channel type is PJSIP if the user has a regular
IP phone.

#. Go to the asterisk server and set the ip address and port where the
asterisk server is configured and set the ARI login and ARI password
field with the username and password defined in the asterisk
configuration file ari.conf. You can see the port and edit the endpoint
configuration, to allow calls, in the asterisk configuration file
pjsip.conf. You also can see all the asterisk servers configured going
to menu entry in Settings -> Technical -> Asterisk Servers.

Usage
=====

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 form view (or any form view with a
phone number).
- 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 to get the
partner/lead/candidate/event 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/Event 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*.

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

Expand Down
2 changes: 2 additions & 0 deletions asterisk_click2dial/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"assets": {
"web.assets_backend": [
"asterisk_click2dial/static/src/scss/*.scss",
"asterisk_click2dial/static/src/components/**/*.js",
"asterisk_click2dial/static/src/components/**/*.xml",
],
},
}
2 changes: 1 addition & 1 deletion asterisk_click2dial/demo/asterisk_click2dial_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<record id="demo_ast_server" model="asterisk.server">
<field name="name">Akretion Asterisk IPBX</field>
<field name="ip_address">asterisk.akretion.com</field>
<field name="ip_address">localhost</field>
<field name="login">odoo</field>
<field name="password">mypassword</field>
<field name="context">from-internal</field>
Expand Down
20 changes: 11 additions & 9 deletions asterisk_click2dial/models/asterisk_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AsteriskServer(models.Model):
port = fields.Integer(
string="Port",
required=True,
default=5038,
default=8088,
help="TCP port on which the Asterisk REST Interface listens. "
"Defined in /etc/asterisk/ari.conf on Asterisk.",
)
Expand Down Expand Up @@ -167,12 +167,16 @@ def test_ari_connection(self):
raise UserError(
_("Connection Test Failed! HTTP error code: %s" % res.status_code)
)
raise UserError(
_(
"Connection Test Successfull! Odoo can successfully login to "
"the Asterisk Manager Interface."
)
)

return {
"type": "ir.actions.client",
"tag": "display_notification",
"params": {
"type": "success",
"message": _("Your request has been successfully sent"),
"next": {"type": "ir.actions.act_window_close"},
},
}

@api.model
def _get_calling_number_from_channel(self, chan, user):
Expand Down Expand Up @@ -208,9 +212,7 @@ def _get_calling_number(self):
)
return False
list_chan = res_req.json()
from pprint import pprint

pprint(list_chan)
_logger.debug("Result of Status ARI request:")
_logger.debug(pformat(list_chan))
for chan in list_chan:
Expand Down
10 changes: 10 additions & 0 deletions asterisk_click2dial/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
To configure this module, you need to:

#. Go to the user data, go to "Telephony" page and set "Resource Name" with the name you want(can be the same as Internal Number when channel type is SIP)
and "Internal Number" with the user's phone number. Also check that the asterisk channel type is PJSIP if the user has a regular IP phone.

#. Go to the asterisk server and set the ip address and port where the asterisk server is configured and set the ARI login and ARI password field with
the username and password defined in the asterisk configuration file ari.conf. You can see the port and edit the endpoint configuration, to allow calls,
in the asterisk configuration file pjsip.conf. You also can see all the asterisk servers configured going to menu entry
in Settings -> Technical -> Asterisk Servers.

58 changes: 58 additions & 0 deletions asterisk_click2dial/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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 form view (or any form view with a
phone number).
- 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 to get the
partner/lead/candidate/event 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/Event 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*.
102 changes: 92 additions & 10 deletions asterisk_click2dial/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -437,39 +437,121 @@ <h1 class="title">Asterisk connector</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>To configure this module, you need to:</p>
<p>#. Go to the user data, go to “Telephony” page and set “Resource Name”
with the name you want(can be the same as Internal Number when channel
type is SIP) and “Internal Number” with the user’s phone number. Also
check that the asterisk channel type is PJSIP if the user has a regular
IP phone.</p>
<p>#. Go to the asterisk server and set the ip address and port where the
asterisk server is configured and set the ARI login and ARI password
field with the username and password defined in the asterisk
configuration file ari.conf. You can see the port and edit the endpoint
configuration, to allow calls, in the asterisk configuration file
pjsip.conf. You also can see all the asterisk servers configured going
to menu entry in Settings -&gt; Technical -&gt; Asterisk Servers.</p>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<p>The technical name of this module is <strong>asterisk_click2dial</strong>, but this
module implements much more than a simple <em>click2dial</em> ! This module
adds 3 functionalities:</p>
<ol class="arabic">
<li><p class="first">It adds a <em>Dial</em> button in the partner form view so that users can
directly dial a phone number through Asterisk. This feature is
usually known as <em>click2dial</em>. Here is how it works :</p>
<ul class="simple">
<li>In Odoo, the user clicks on the <em>Dial</em> button next to a phone
number field in the partner form view (or any form view with a
phone number).</li>
<li>Odoo connects to the Asterisk Manager Interface and Asterisk makes
the user’s phone ring.</li>
<li>The user answers his own phone (if he doesn’t, the process stops
here).</li>
<li>Asterisk dials the phone number found in Odoo in place of the
user.</li>
<li>If the remote party answers, the user can talk to his
correspondent.</li>
</ul>
</li>
<li><p class="first">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:</p>
<ul class="simple">
<li>On incoming phone calls, the Asterisk dialplan executes an AGI
script <strong>set_name_incoming_timeout.sh</strong>.</li>
<li>The <em>set_name_incoming_timeout.sh</em> script calls the
<em>set_name_agi.py</em> script with a short timeout.</li>
<li>The <em>set_name_agi.py</em> 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.</li>
<li>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.</li>
</ul>
<p>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 <em>set_name_outgoing_timeout.sh</em>.</p>
</li>
<li><p class="first">It adds a phone icon (<em>Open Caller</em>) in the top menu bar to get the
partner/lead/candidate/event registrations corresponding to the
calling party in one click. Here is how it works :</p>
<ul class="simple">
<li>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.</li>
<li>If it finds a phone call involving the user’s phone, it gets the
phone number of the calling party.</li>
<li>It searches the phone number of the calling party in the
Partners/Leads/Candidates/Event 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 <em>Phone</em> or <em>Mobile</em>
number or update an existing Partner.</li>
</ul>
<p>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
<em>base_phone_popup</em>.</p>
</li>
</ol>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/connector-telephony/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/connector-telephony/issues/new?body=module:%20asterisk_click2dial%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<ul class="simple">
<li>Akretion</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
Expand Down
Loading

0 comments on commit 004ddf6

Please sign in to comment.