diff --git a/asterisk_click2dial/README.rst b/asterisk_click2dial/README.rst new file mode 100644 index 0000000..bfe0dc2 --- /dev/null +++ b/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 +`_. 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. + diff --git a/asterisk_click2dial/__openerp__.py b/asterisk_click2dial/__openerp__.py index 5859643..31c1228 100644 --- a/asterisk_click2dial/__openerp__.py +++ b/asterisk_click2dial/__openerp__.py @@ -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'], diff --git a/asterisk_click2dial/asterisk_click2dial.py b/asterisk_click2dial/asterisk_click2dial.py index 15e0874..be702b2 100644 --- a/asterisk_click2dial/asterisk_click2dial.py +++ b/asterisk_click2dial/asterisk_click2dial.py @@ -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( diff --git a/asterisk_click2dial/scripts/set_name_agi.py b/asterisk_click2dial/scripts/set_name_agi.py index f4a8761..c653777 100755 --- a/asterisk_click2dial/scripts/set_name_agi.py +++ b/asterisk_click2dial/scripts/set_name_agi.py @@ -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. " diff --git a/asterisk_click2dial/static/src/js/asterisk_click2dial.js b/asterisk_click2dial/static/src/js/asterisk_click2dial.js index 61ad788..e4981b0 100644 --- a/asterisk_click2dial/static/src/js/asterisk_click2dial.js +++ b/asterisk_click2dial/static/src/js/asterisk_click2dial.js @@ -35,14 +35,12 @@ 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', @@ -50,13 +48,13 @@ click2dial.OpenCaller = Widget.extend({ 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); @@ -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({ @@ -90,7 +88,7 @@ click2dial.OpenCaller = Widget.extend({ // attach the phone logo/button to the systray asterisk_button.appendTo($('.oe_systray')); }); - }, + } }); }); diff --git a/base_phone/fields.py b/base_phone/fields.py index 05aad20..d8fb838 100644 --- a/base_phone/fields.py +++ b/base_phone/fields.py @@ -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): @@ -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 @@ -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 diff --git a/base_phone/models/phone_common.py b/base_phone/models/phone_common.py index 8a2a3eb..1786c47 100644 --- a/base_phone/models/phone_common.py +++ b/base_phone/models/phone_common.py @@ -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' diff --git a/base_phone/models/res_partner.py b/base_phone/models/res_partner.py index aa56956..c13d8e1 100644 --- a/base_phone/models/res_partner.py +++ b/base_phone/models/res_partner.py @@ -4,7 +4,7 @@ from openerp import models, api -from openerp.addons.base_phone import fields +from .. import fields class ResPartner(models.Model): diff --git a/base_phone/static/src/js/phone_widget.js b/base_phone/static/src/js/phone_widget.js index b51b2aa..5dedc8a 100644 --- a/base_phone/static/src/js/phone_widget.js +++ b/base_phone/static/src/js/phone_widget.js @@ -31,8 +31,7 @@ var FieldPhone = formwidgets.FieldChar.extend({ raw_phone_num = phone_num.replace(/ /g, ''); raw_phone_num = raw_phone_num.replace(/-/g, ''); this.$el.find('a.oe_form_uri').attr('href', 'tel:' + raw_phone_num).text(phone_num); - } - else { + } else { this.$el.find('a.oe_form_uri').attr('href', '').text(''); } var click2dial_text = ''; @@ -64,7 +63,7 @@ var FieldPhone = formwidgets.FieldChar.extend({ var context = { 'click2dial_model': self.view.dataset.model, 'click2dial_id': self.view.datarecord.id, - 'phone_number': raw_phone_num, + 'phone_number': raw_phone_num }; var action = { name: r.action_name, @@ -73,7 +72,7 @@ var FieldPhone = formwidgets.FieldChar.extend({ view_mode: 'form', views: [[false, 'form']], target: 'new', - context: context, + context: context }; web_client.action_manager.do_action(action); } @@ -106,8 +105,7 @@ var FieldFax = formwidgets.FieldChar.extend({ var raw_fax_num = fax_num.replace(/ /g, ''); raw_fax_num = raw_fax_num.replace(/-/g, ''); this.$el.find('a').attr('href', 'fax:' + raw_fax_num).text(fax_num); - } - else { + } else { this.$el.find('a').attr('href', '').text(''); } } diff --git a/base_phone/wizard/number_not_found.py b/base_phone/wizard/number_not_found.py index 57b1498..8254eec 100644 --- a/base_phone/wizard/number_not_found.py +++ b/base_phone/wizard/number_not_found.py @@ -5,9 +5,11 @@ from openerp import models, fields, api, _ from openerp.exceptions import UserError import logging -import phonenumbers - _logger = logging.getLogger(__name__) +try: + import phonenumbers +except (ImportError, IOError) as err: + _logger.debug(err) class NumberNotFound(models.TransientModel): diff --git a/base_phone_popup/README.rst b/base_phone_popup/README.rst new file mode 100644 index 0000000..e1fd1c9 --- /dev/null +++ b/base_phone_popup/README.rst @@ -0,0 +1,86 @@ +.. 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 + +================= +Base Phone Pop-up +================= + +When the user receives a phone call, Odoo can automatically open the +corresponding partner/lead/employee/... in a pop-up without any action from +the user. + +Installation +============ + +To install this module, you need to: + +* Click on the module and install it + +The module *web_action_request* can be downloaded with Mercurial: + +hg clone http://bitbucket.org/anybox/web_action_request + +It depends on 2 other modules, *web_longpolling* and *web_socketio*, that can +be downloaded with this command: + +hg clone http://bitbucket.org/anybox/web_socketio + +You will find some hints in this documentation : +https://bitbucket.org/anybox/web_action_request + +Warning : proxying WebSockets is only supported since Nginx 1.3.13 ; the +feature provided by this module won't work with older versions of Nginx. + +TODO : document this new feature on the Akretion Web site : +http://www.akretion.com/products-and-services/openerp-asterisk-voip-connector + +Configuration +============= + +To configure this module, you need to: + +* Configure users under Settings > Users > $USER + +Usage +===== + +* Install, configure user, use. + +Known issues / Roadmap +====================== + +* None + +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 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. + diff --git a/base_phone_popup/__openerp__.py b/base_phone_popup/__openerp__.py index 29f9cb0..64c8279 100644 --- a/base_phone_popup/__openerp__.py +++ b/base_phone_popup/__openerp__.py @@ -9,32 +9,6 @@ 'category': 'Phone', 'license': 'AGPL-3', 'summary': 'Pop-up the related form view to the user on incoming calls', - 'description': """ -Base Phone Pop-up -================= - -When the user receives a phone call, OpenERP can automatically open the -corresponding partner/lead/employee/... in a pop-up without any action from the -user. - -The module *web_action_request* can be downloaded with Mercurial: - -hg clone http://bitbucket.org/anybox/web_action_request - -It depends on 2 other modules, *web_longpolling* and *web_socketio*, that can -be downloaded with this command: - -hg clone http://bitbucket.org/anybox/web_socketio - -You will find some hints in this documentation : -https://bitbucket.org/anybox/web_action_request - -Warning : proxying WebSockets is only supported since Nginx 1.3.13 ; the -feature provided by this module won't work with older versions of Nginx. - -TODO : document this new feature 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', 'web_action_request'], diff --git a/crm_phone/README.rst b/crm_phone/README.rst new file mode 100644 index 0000000..a24eb7c --- /dev/null +++ b/crm_phone/README.rst @@ -0,0 +1,70 @@ +.. 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 + +========= +CRM Phone +========= + +This module validate phone numbers in the CRM module, just like the +*base_phone* module valide phone numbers in the Partner form. Please refer to +the description of the *base_phone* module for more information. + +This module is independant from the Asterisk and FreeSWITCH connectors. + +Please contact Alexis de Lattre from Akretion +for any help or question about this module. + +Installation +============ + +To install this module, you need to: + +* Click on the module and install it + +Configuration +============= + +* None beyond *base_phone* configuration. + +Usage +===== + + +Known issues / Roadmap +====================== + +* None + +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 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. + diff --git a/crm_phone/__openerp__.py b/crm_phone/__openerp__.py index 9cb7bb7..0fdc4c9 100644 --- a/crm_phone/__openerp__.py +++ b/crm_phone/__openerp__.py @@ -8,23 +8,11 @@ 'category': 'Phone', 'license': 'AGPL-3', 'summary': 'Validate phone numbers in CRM', - 'description': """ -CRM Phone -========= - -This module validate phone numbers in the CRM module, just like the -*base_phone* module valide phone numbers in the Partner form. Please refer to -the description of the *base_phone* module for more information. - -This module is independant from the Asterisk connector. - -Please contact Alexis de Lattre from Akretion -for any help or question about this module. -""", 'author': "Akretion,Odoo Community Association (OCA)", 'website': 'http://www.akretion.com/', 'depends': ['base_phone', 'crm'], 'conflicts': ['crm_voip'], + 'external_dependencies': {'python': ['phonenumbers']}, 'data': [ 'security/phonecall_security.xml', 'security/ir.model.access.csv', diff --git a/crm_phone/crm_phone.py b/crm_phone/crm_phone.py index 599c563..020ebaa 100644 --- a/crm_phone/crm_phone.py +++ b/crm_phone/crm_phone.py @@ -16,7 +16,7 @@ class CrmLead(models.Model): phonecall_ids = fields.One2many( 'crm.phonecall', 'opportunity_id', string='Phone Calls') phonecall_count = fields.Integer( - compute='_count_phonecalls', string='Number of Phonecalls', + compute='_compute_count_phonecalls', string='Number of Phonecalls', readonly=True) @api.multi @@ -39,7 +39,7 @@ class CrmLead(models.Model): @api.multi @api.depends('phonecall_ids') - def _count_phonecalls(self): + def _compute_count_phonecalls(self): cpo = self.env['crm.phonecall'] for lead in self: try: @@ -142,12 +142,12 @@ class ResPartner(models.Model): phonecall_ids = fields.One2many( 'crm.phonecall', 'partner_id', string='Phone Calls') phonecall_count = fields.Integer( - compute='_count_phonecalls', string='Number of Phonecalls', + compute='_compute_count_phonecalls', string='Number of Phonecalls', readonly=True) @api.multi @api.depends('phonecall_ids') - def _count_phonecalls(self): + def _compute_count_phonecalls(self): cpo = self.env['crm.phonecall'] for partner in self: try: diff --git a/crm_phone/wizard/create_crm_phonecall.py b/crm_phone/wizard/create_crm_phonecall.py index 733ffad..965faf9 100644 --- a/crm_phone/wizard/create_crm_phonecall.py +++ b/crm_phone/wizard/create_crm_phonecall.py @@ -3,7 +3,12 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from openerp import models, api, _ -import phonenumbers +import logging +_logger = logging.getLogger(__name__) +try: + import phonenumbers +except (ImportError, IOError) as err: + _logger.debug(err) class WizardCreateCrmPhonecall(models.TransientModel): diff --git a/freeswitch_click2dial/README.rst b/freeswitch_click2dial/README.rst index 70e1022..8834b1e 100644 --- a/freeswitch_click2dial/README.rst +++ b/freeswitch_click2dial/README.rst @@ -54,7 +54,7 @@ Usage To use this module, you need to: -* See scripts/get_caller_name.py to see how to set caller and callee name +* 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. @@ -77,13 +77,13 @@ To use this module, you need to: instructions in the script on the Odoo/Odoo server. This works for incoming and outgoing calls, per instructions in the script. -3) *Open Caller* Here is how it works : +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 + 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 + 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, diff --git a/freeswitch_click2dial/__openerp__.py b/freeswitch_click2dial/__openerp__.py index 94186bf..9b7795f 100644 --- a/freeswitch_click2dial/__openerp__.py +++ b/freeswitch_click2dial/__openerp__.py @@ -6,7 +6,7 @@ { 'name': 'FreeSWITCH Click2dial', - 'version': '9.0.1.0.0', + 'version': '9.0.1.0.1', 'category': 'Phone', 'license': 'AGPL-3', 'summary': 'FreeSWITCH-Odoo connector', diff --git a/freeswitch_click2dial/controller.py b/freeswitch_click2dial/controller.py index c377f6e..3f8d94f 100644 --- a/freeswitch_click2dial/controller.py +++ b/freeswitch_click2dial/controller.py @@ -14,5 +14,5 @@ class FreeSWITCHClick2dialController(http.Controller): '/freeswitch_click2dial/get_record_from_my_channel/', type='json', auth='public') def get_record_from_my_channel(self, **kw): - res = http.request.env['freeswitch.server'].get_record_from_my_channel() - return res + FreeswitchServer = http.request.env['freeswitch.server'] + return FreeswitchServer.get_record_from_my_channel() diff --git a/freeswitch_click2dial/freeswitch_click2dial.py b/freeswitch_click2dial/freeswitch_click2dial.py index 64c243d..d332292 100644 --- a/freeswitch_click2dial/freeswitch_click2dial.py +++ b/freeswitch_click2dial/freeswitch_click2dial.py @@ -19,7 +19,8 @@ _logger = logging.getLogger(__name__) class FreeSWITCHServer(models.Model): - '''FreeSWITCH server object, stores the parameters of the FreeSWITCH Servers''' + '''FreeSWITCH server object, stores the parameters of the FreeSWITCH + Servers''' _name = "freeswitch.server" _description = "FreeSWITCH Servers" name = fields.Char(string='FreeSWITCH Server Name', required=True) @@ -72,10 +73,10 @@ class FreeSWITCHServer(models.Model): 'out_prefix', 'wait_time', 'port', 'context', 'alert_info', '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) - password = ('Event Socket 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) + password = (_('Event Socket password'), server.password) if out_prefix[1] and not out_prefix[1].isdigit(): raise ValidationError( @@ -130,7 +131,7 @@ class FreeSWITCHServer(models.Model): fs_manager = ESL.ESLconnection( str(fs_server.ip_address), str(fs_server.port), str(fs_server.password)) - except Exception, e: + except Exception as e: _logger.error( "Error in the request to the FreeSWITCH Event Socket %s", fs_server.ip_address) @@ -148,7 +149,7 @@ class FreeSWITCHServer(models.Model): fs_manager = ESL.ESLconnection( str(self.ip_address), str(self.port), str(self.password)) - except Exception, e: + except Exception as e: raise UserError( _("Connection Test Failed! The error message is: %s" % e)) finally: @@ -159,7 +160,7 @@ class FreeSWITCHServer(models.Model): "Password.")) else: fs_manager.disconnect() - except Exception, e: + except Exception as e: pass raise UserError(_( "Connection Test Successfull! Odoo can successfully login to " @@ -190,7 +191,7 @@ class FreeSWITCHServer(models.Model): calling_party_number = f['rows'][x]['dest'] else: calling_party_number = f['rows'][x]['cid_num'] - except Exception, e: + except Exception as e: _logger.error( "Error in the Status request to FreeSWITCH server %s", fs_server.ip_address) @@ -398,7 +399,7 @@ class PhoneCommon(models.AbstractModel): '\'' + self.get_name_from_phone_number(fs_number) + '\' ' + \ fs_number fs_manager.api('originate', dial_string.encode('utf-8')) - except Exception, e: + except Exception as e: _logger.error( "Error in the Originate request to FreeSWITCH server %s", fs_server.ip_address) diff --git a/freeswitch_click2dial/scripts/get_caller_name.py b/freeswitch_click2dial/scripts/get_caller_name.py index f5657cd..361f1bb 100644 --- a/freeswitch_click2dial/scripts/get_caller_name.py +++ b/freeswitch_click2dial/scripts/get_caller_name.py @@ -3,6 +3,7 @@ # (c) 2010-2014 Alexis de Lattre # (c) 2014-2016 Trever L. Adams # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +# flake8: noqa: E501 """ Name lookup in OpenERP for incoming and outgoing calls with an FreeSWITCH system @@ -36,9 +37,7 @@ Notify should be the internal number of the called parties. This should be comma (,) delimited, not :_: delimited. It is up to you to format the extensions list appropriately. The persons who are at extensions in the - notify list will receive a poppup if so configured and if they are logged in. - The notify list actually shouldn't be in the cidlookup.conf, but should be - used when doing notify (in an on answer hook for example). + notify list will receive a pop-up if so configured and if they are logged in. From the dialplan, do something like this . @@ -57,11 +56,10 @@ """ __author__ = "Trever Adams " -__date__ = "August 2016" -__version__ = "0.5" +__date__ = "June 2017" +__version__ = "0.6" import sys -sys.path.append('.') import xmlrpclib from cgi import parse_qs, escape import unicodedata @@ -69,7 +67,7 @@ import unicodedata # Name that will be displayed if there is no match # and no geolocalisation -not_found_name = "Not in OpenERP" +not_found_name = "Not in Odoo" # Name used if name and number are both empty unknown_name = "unknown" @@ -99,7 +97,7 @@ def geolocate_phone_number(number, my_country_code, lang): res = '' phonenum = phonenumbers.parse(number, my_country_code.upper()) - city = phonenumbers.geocoder.description_for_number(phonenum, lang.lower()) + city = geocoder.description_for_number(phonenum, lang.lower()) country_code = phonenumbers.region_code_for_number(phonenum) # We don't display the country name when it's my own country if country_code == my_country_code.upper(): @@ -107,7 +105,7 @@ def geolocate_phone_number(number, my_country_code, lang): res = city else: # Convert country code to country name - country = phonenumbers.geocoder._region_display_name( + country = geocoder._region_display_name( country_code, lang.lower()) if country and city: res = country + ' ' + city diff --git a/freeswitch_click2dial/static/src/js/freeswitch_click2dial.js b/freeswitch_click2dial/static/src/js/freeswitch_click2dial.js index 7fd966e..749ae9e 100644 --- a/freeswitch_click2dial/static/src/js/freeswitch_click2dial.js +++ b/freeswitch_click2dial/static/src/js/freeswitch_click2dial.js @@ -32,14 +32,12 @@ click2dial.OpenCaller = Widget.extend({ _t('Failure'), _t('Problem in the connection to FreeSWITCH'), 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', @@ -47,13 +45,13 @@ click2dial.OpenCaller = Widget.extend({ 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); @@ -71,12 +69,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({ @@ -87,7 +85,7 @@ click2dial.OpenCaller = Widget.extend({ // attach the phone logo/button to the systray freeswitch_button.appendTo($('.oe_systray')); }); - }, + } }); });