diff --git a/asterisk_click2dial/README.rst b/asterisk_click2dial/README.rst index 77273baf2..22855d2ff 100644 --- a/asterisk_click2dial/README.rst +++ b/asterisk_click2dial/README.rst @@ -17,78 +17,79 @@ Asterisk connector :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fconnector--telephony-lightgray.png?logo=github - :target: https://github.com/OCA/connector-telephony/tree/16.0/asterisk_click2dial + :target: https://github.com/OCA/connector-telephony/tree/17.0/asterisk_click2dial :alt: OCA/connector-telephony .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/connector-telephony-16-0/connector-telephony-16-0-asterisk_click2dial + :target: https://translation.odoo-community.org/projects/connector-telephony-17-0/connector-telephony-17-0-asterisk_click2dial :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/connector-telephony&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/connector-telephony&target_branch=17.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| -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*. - -A detailed documentation for this module is available on `this page `_ of Akretion's Web site. +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*. + +A detailed documentation for this module is available on `this +page `__ +of Akretion's Web site. **Table of contents** @@ -101,7 +102,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. 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 -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -109,17 +110,17 @@ Credits ======= Authors -~~~~~~~ +------- * Akretion Contributors -~~~~~~~~~~~~ +------------ -* Alexis de Lattre +- Alexis de Lattre Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -139,6 +140,6 @@ Current `maintainer `__: |maintainer-alexis-via| -This module is part of the `OCA/connector-telephony `_ project on GitHub. +This module is part of the `OCA/connector-telephony `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/asterisk_click2dial/models/asterisk_server.py b/asterisk_click2dial/models/asterisk_server.py index e6d51f842..4796c4e28 100644 --- a/asterisk_click2dial/models/asterisk_server.py +++ b/asterisk_click2dial/models/asterisk_server.py @@ -104,8 +104,8 @@ def _check_validity(self): if out_prefix[1] and not out_prefix[1].isdigit(): raise ValidationError( _( - f"Only use digits for the {out_prefix[0]} on the Asterisk server " - f"{server.name}" + f"Only use digits for the {out_prefix[0]} on the Asterisk " + f"server {server.name}" ) ) if server.wait_time < 1 or server.wait_time > 120: @@ -136,8 +136,8 @@ def _check_validity(self): except UnicodeEncodeError: raise ValidationError( _( - f"The {check_str[0]} should only have ASCII caracters for " - f"the Asterisk server {server.name}" + f"The {check_str[0]} should only have ASCII " + f"caracters for the Asterisk server {server.name}" ) ) from None @@ -170,7 +170,8 @@ def test_ari_connection(self): "params": { "type": "success", "message": _( - "Connection Test Successfull! Odoo can successfully login to Asterisk." + "Connection Test Successfull! Odoo can successfully login to" + "Asterisk." ), "next": {"type": "ir.actions.act_window_close"}, }, diff --git a/asterisk_click2dial/models/phone_common.py b/asterisk_click2dial/models/phone_common.py index c8fe205e1..0b51fdc69 100644 --- a/asterisk_click2dial/models/phone_common.py +++ b/asterisk_click2dial/models/phone_common.py @@ -29,7 +29,7 @@ def click2dial(self, erp_number): # Add 'out prefix' if ast_server.out_prefix: _logger.debug("Out prefix = %s", ast_server.out_prefix) - ast_number = "%s%s" % (ast_server.out_prefix, ast_number) + ast_number = f"{ast_server.out_prefix}{ast_number}" _logger.debug("Number to be sent to Asterisk = %s", ast_number) # The user should have a CallerID diff --git a/asterisk_click2dial/pyproject.toml b/asterisk_click2dial/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/asterisk_click2dial/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/asterisk_click2dial/readme/CONTRIBUTORS.md b/asterisk_click2dial/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..b61afe5d0 --- /dev/null +++ b/asterisk_click2dial/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Alexis de Lattre \<\> diff --git a/asterisk_click2dial/readme/CONTRIBUTORS.rst b/asterisk_click2dial/readme/CONTRIBUTORS.rst deleted file mode 100644 index ff65d68ce..000000000 --- a/asterisk_click2dial/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1 +0,0 @@ -* Alexis de Lattre diff --git a/asterisk_click2dial/readme/DESCRIPTION.md b/asterisk_click2dial/readme/DESCRIPTION.md new file mode 100644 index 000000000..1b9a2130d --- /dev/null +++ b/asterisk_click2dial/readme/DESCRIPTION.md @@ -0,0 +1,62 @@ +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*. + +A detailed documentation for this module is available on [this +page](http://www.akretion.com/products-and-services/openerp-asterisk-voip-connector) +of Akretion's Web site. diff --git a/asterisk_click2dial/readme/DESCRIPTION.rst b/asterisk_click2dial/readme/DESCRIPTION.rst deleted file mode 100644 index d01bc593c..000000000 --- a/asterisk_click2dial/readme/DESCRIPTION.rst +++ /dev/null @@ -1,61 +0,0 @@ -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*. - -A detailed documentation for this module is available on `this page `_ of Akretion's Web site. diff --git a/asterisk_click2dial/scripts/set_name_agi.py b/asterisk_click2dial/scripts/set_name_agi.py index 3c8a678c4..43a885cdb 100755 --- a/asterisk_click2dial/scripts/set_name_agi.py +++ b/asterisk_click2dial/scripts/set_name_agi.py @@ -124,7 +124,7 @@ def geolocate_phone_number(number, my_country_code, lang): # Convert country code to country name country = phonenumbers.geocoder._region_display_name(country_code, lang.lower()) if country and city: - res = "%s %s" % (country, city) + res = f"{country}{city}" elif country and not city: res = country return res @@ -232,8 +232,7 @@ def main(args): if args.geoloc: # if the number is not found in Odoo, we try to geolocate agi.verbose( - "Trying to geolocate with country %s and lang %s" - % (args.country, args.lang) + f"Trying to geolocate with country {args.country} and lang {args.lang}" ) res = geolocate_phone_number(phone_number, args.country, args.lang) else: @@ -253,7 +252,7 @@ def main(args): if args.outgoing: agi.set_variable("connectedlinename", res) else: - agi.set_callerid('"%s"<%s>' % (res, phone_number)) + agi.set_callerid(f"{res}<{phone_number}>") if __name__ == "__main__": diff --git a/asterisk_click2dial/static/description/index.html b/asterisk_click2dial/static/description/index.html index 05de829a4..fb3a97e62 100644 --- a/asterisk_click2dial/static/description/index.html +++ b/asterisk_click2dial/static/description/index.html @@ -1,4 +1,3 @@ - @@ -369,61 +368,71 @@

Asterisk connector

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:70c4fbe57dbcfd18cf15685ed8361c0af932e8f5c65668c39a947eeccfd1cc1e !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/connector-telephony Translate me on Weblate Try me on Runboat

-

The technical name of this module is asterisk_click2dial, but this module -implements much more than a simple click2dial ! This module adds 3 -functionalities:

+

Beta License: AGPL-3 OCA/connector-telephony Translate me on Weblate Try me on Runboat

+

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 :

    +
  2. 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.
    • +
    • 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.
  3. -
  4. 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:

    +
  5. 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.
    • +
    • 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.

    +

    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.

  6. -
  7. 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 :

    +
  8. 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.
    • +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.
    • +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.

    +

    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 this page of Akretion’s Web site.

+

A detailed documentation for this module is available on this +page +of Akretion’s Web site.

Table of contents

    @@ -441,7 +450,7 @@

    Bug Tracker

    Bugs are tracked on GitHub Issues. 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 -feedback.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

@@ -467,7 +476,7 @@

Maintainers

promote its widespread use.

Current maintainer:

alexis-via

-

This module is part of the OCA/connector-telephony project on GitHub.

+

This module is part of the OCA/connector-telephony project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/requirements.txt b/requirements.txt index 7dcadefb7..6d7777cf5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ # generated from manifests external_dependencies phonenumbers +requests