From c74613e9488dc88fab47eac6c020dd23de20c9a7 Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Wed, 5 Nov 2014 14:38:06 -0500 Subject: [PATCH] Fix code style --- asterisk_click2dial/__openerp__.py | 58 +++++++++++++++------- asterisk_click2dial/asterisk_click2dial.py | 13 +++-- asterisk_click2dial_crm/__init__.py | 4 +- asterisk_click2dial_crm/__openerp__.py | 17 +++++-- base_phone/__openerp__.py | 23 +++++++-- base_phone/base_phone.py | 12 ++--- base_phone/wizard/number_not_found.py | 6 ++- base_phone_popup/__openerp__.py | 17 +++++-- crm_claim_phone/__openerp__.py | 7 ++- crm_phone/__openerp__.py | 7 ++- event_phone/__openerp__.py | 7 ++- hr_phone/__openerp__.py | 7 ++- hr_recruitment_phone/__openerp__.py | 7 ++- 13 files changed, 128 insertions(+), 57 deletions(-) diff --git a/asterisk_click2dial/__openerp__.py b/asterisk_click2dial/__openerp__.py index b59868d..8110009 100644 --- a/asterisk_click2dial/__openerp__.py +++ b/asterisk_click2dial/__openerp__.py @@ -30,13 +30,19 @@ Asterisk-OpenERP 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: +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 : +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 OpenERP, the user clicks on the *Dial* button next to a phone number field in the partner view. + * In OpenERP, the user clicks on the *Dial* button next to a phone number + field in the partner view. - * OpenERP connects to the Asterisk Manager Interface and Asterisk makes the user's phone ring. + * OpenERP 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). @@ -44,30 +50,48 @@ The technical name of this module is *asterisk_click2dial*, but this module impl * 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 OpenERP. Here is how it works : +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 OpenERP. Here is how it works: - * On incoming phone calls, the Asterisk dialplan executes an AGI script "set_name_incoming_timeout.sh". + * 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_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 OpenERP server to try to find the name of the person corresponding to the phone number presented by the calling party. + * The "set_name_agi.py" script will make an XML-RPC request on the OpenERP + 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. + * 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". -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 : +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, OpenERP sends a query to the Asterisk Manager Interface to get a list of the current phone calls + * When the user clicks on the phone icon, OpenERP 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 + * 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 OpenERP. 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 searches the phone number of the calling party in the + Partners/Leads/Candidates/Registrations of OpenERP. 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 the Akretion Web site : http://www.akretion.com/en/products-and-services/openerp-asterisk-voip-connector +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', 'website': 'http://www.akretion.com/', diff --git a/asterisk_click2dial/asterisk_click2dial.py b/asterisk_click2dial/asterisk_click2dial.py index 587c391..cd8df44 100644 --- a/asterisk_click2dial/asterisk_click2dial.py +++ b/asterisk_click2dial/asterisk_click2dial.py @@ -237,8 +237,7 @@ class asterisk_server(orm.Model): raise orm.except_orm( _('Error:'), _("Problem in the request from OpenERP to Asterisk. " - "Here is the error message: %s" % e)) - return False + "Here is the error message: %s" % e)) return (user, ast_server, ast_manager) @@ -260,10 +259,10 @@ class asterisk_server(orm.Model): ast_manager.Logoff() except Exception: pass - raise orm.except_orm( - _("Connection Test Successfull!"), - _("OpenERP can successfully login to the Asterisk Manager " - "Interface.")) + raise orm.except_orm( + _("Connection Test Successfull!"), + _("OpenERP can successfully login to the Asterisk Manager " + "Interface.")) def _get_calling_number(self, cr, uid, context=None): @@ -318,7 +317,7 @@ class asterisk_server(orm.Model): def get_record_from_my_channel(self, cr, uid, context=None): calling_number = self.pool['asterisk.server']._get_calling_number( cr, uid, context=context) - #calling_number = "0641981246" + # calling_number = "0641981246" if calling_number: record = self.pool['phone.common'].get_record_from_phone_number( cr, uid, calling_number, context=context) diff --git a/asterisk_click2dial_crm/__init__.py b/asterisk_click2dial_crm/__init__.py index 817dd74..c561ae1 100644 --- a/asterisk_click2dial_crm/__init__.py +++ b/asterisk_click2dial_crm/__init__.py @@ -6,8 +6,8 @@ # @author: Alexis de Lattre # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, diff --git a/asterisk_click2dial_crm/__openerp__.py b/asterisk_click2dial_crm/__openerp__.py index 61b6645..21b9996 100644 --- a/asterisk_click2dial_crm/__openerp__.py +++ b/asterisk_click2dial_crm/__openerp__.py @@ -35,13 +35,22 @@ This module adds CRM-specific features to the asterisk_click2dial module. It adds 2 features : -First, when you do a click2dial, OpenERP will propose you to create an outbound phone call in the CRM ; if you answer 'Yes', it will create the phone call in the CRM and open it in a new tab. If some users don't want to be asked to create a phone call in the CRM each time they do a click2dial, you should disable the corresponding option in the 'Telephony' tab of the 'User' form. +First, when you do a click2dial, OpenERP will propose you to create an outbound +phone call in the CRM ; if you answer 'Yes', it will create the phone call in +the CRM and open it in a new tab. If some users don't want to be asked to +create a phone call in the CRM each time they do a click2dial, you should +disable the corresponding option in the 'Telephony' tab of the 'User' form. -Second, when you receive a phone call and run the wizard "Open calling partner", if the partner is found in OpenERP, you will see a button that proposes to create an inbound phone call in the CRM. +Second, when you receive a phone call and run the wizard +"Open calling partner", if the partner is found in OpenERP, you will see a +button that proposes to create an inbound phone call in the CRM. -This module has been initially developped by Zikzakmedia and has been completely re-written by Akretion. +This module has been initially developped by Zikzakmedia and has been +completely re-written by Akretion. -A detailed documentation for the OpenERP-Asterisk connector is available on the Akretion Web site : http://www.akretion.com/en/products-and-services/openerp-asterisk-voip-connector +A detailed documentation for the OpenERP-Asterisk connector is available on the +Akretion Web site : +http://www.akretion.com/products-and-services/openerp-asterisk-voip-connector """, "depends": [ 'asterisk_click2dial', diff --git a/base_phone/__openerp__.py b/base_phone/__openerp__.py index 8a5432e..907c7cc 100644 --- a/base_phone/__openerp__.py +++ b/base_phone/__openerp__.py @@ -30,11 +30,21 @@ Base Phone ========== -This module validate phone numbers using the *phonenumbers* Python library, which is a port of the library used in Android smartphones. For example, if your user is linked to a French company and you update the form view of a partner with a badly written French phone number such as '01-55-42-12-42', Odoo will automatically update the phone number to E.164 format '+33155421242' and display in the form view of the partner the readable equivalent '+33 1 55 42 12 42'. +This module validate phone numbers using the *phonenumbers* Python library, +which is a port of the library used in Android smartphones. For example, if +your user is linked to a French company and you update the form view of a +partner with a badly written French phone number such as '01-55-42-12-42', +Odoo will automatically update the phone number to E.164 format '+33155421242' +and display in the form view of the partner the readable equivalent +'+33 1 55 42 12 42'. -This module also adds *tel:* links on phone numbers and *fax:* links on fax numbers. If you have a softphone or a client software on your PC that is associated with *tel:* links, the softphone should propose you to dial the phone number when you click on such a link. +This module also adds *tel:* links on phone numbers and *fax:* links on fax +numbers. If you have a softphone or a client software on your PC that is +associated with *tel:* links, the softphone should propose you to dial the +phone number when you click on such a link. -This module also updates the format() function for reports and adds 2 arguments : +This module also updates the format() function for reports and adds 2 +arguments : * *phone* : should be True for a phone number, False (default) otherwize. * *phone_format* : it can have 3 possible values : @@ -42,11 +52,14 @@ This module also updates the format() function for reports and adds 2 arguments * *national* : the report will display '01 55 42 12 42' * *e164* : the report will display '+33155421242' -For example, in the Sale Order report, to display the phone number of the Salesman, you can write : o.user_id and o.user_id.phone and format(o.user_id.phone, phone=True, phone_format='national') or '' +For example, in the Sale Order report, to display the phone number of the +Salesman, you can write : o.user_id and o.user_id.phone and +format(o.user_id.phone, phone=True, phone_format='national') or '' This module is independant from the Asterisk connector. -Please contact Alexis de Lattre from Akretion for any help or question about this module. +Please contact Alexis de Lattre from Akretion +for any help or question about this module. """, 'author': 'Akretion', 'website': 'http://www.akretion.com/', diff --git a/base_phone/base_phone.py b/base_phone/base_phone.py index 0edd5d1..91309d7 100644 --- a/base_phone/base_phone.py +++ b/base_phone/base_phone.py @@ -60,14 +60,14 @@ class phone_common(orm.AbstractModel): result[record['id']][tofield] = res return result - def _generic_reformat_phonenumbers( - self, cr, uid, vals, - phonefields=[ + def _generic_reformat_phonenumbers(self, cr, uid, vals, phonefields=None, + context=None): + """Reformat phone numbers in E.164 format i.e. +33141981242""" + if phonefields is None: + phonefields = [ 'phone', 'partner_phone', 'work_phone', 'fax', 'mobile', 'partner_mobile', 'mobile_phone', - ], - context=None): - """Reformat phone numbers in E.164 format i.e. +33141981242""" + ] if any([vals.get(field) for field in phonefields]): user = self.pool['res.users'].browse(cr, uid, uid, context=context) # country_id on res.company is a fields.function that looks at diff --git a/base_phone/wizard/number_not_found.py b/base_phone/wizard/number_not_found.py index 9a45b7f..7d2778f 100644 --- a/base_phone/wizard/number_not_found.py +++ b/base_phone/wizard/number_not_found.py @@ -55,7 +55,8 @@ class number_not_found(orm.TransientModel): def default_get(self, cr, uid, fields_list, context=None): res = super(number_not_found, self).default_get( - cr, uid, fields_list, context=context) + cr, uid, fields_list, context=context + ) if not res: res = {} if res.get('calling_number'): @@ -76,6 +77,9 @@ class number_not_found(orm.TransientModel): if context is None: context = {} wiz = self.browse(cr, uid, ids[0], context=context) + parsed_num = phonenumbers.parse(wiz.e164_number, None) + phonenumbers.number_type(parsed_num) + context['default_%s' % wiz.number_type] = wiz.e164_number action = { 'name': _('Create New Partner'), diff --git a/base_phone_popup/__openerp__.py b/base_phone_popup/__openerp__.py index ce93348..1587dea 100644 --- a/base_phone_popup/__openerp__.py +++ b/base_phone_popup/__openerp__.py @@ -30,21 +30,28 @@ 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. +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: +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 +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. +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/en/products-and-services/openerp-asterisk-voip-connector """, +TODO : document this new feature on the Akretion Web site : +http://www.akretion.com/products-and-services/openerp-asterisk-voip-connector +""", 'author': 'Akretion', 'website': 'http://www.akretion.com/', 'depends': ['base_phone', 'web_action_request'], diff --git a/crm_claim_phone/__openerp__.py b/crm_claim_phone/__openerp__.py index 30172e9..e8cbaa0 100644 --- a/crm_claim_phone/__openerp__.py +++ b/crm_claim_phone/__openerp__.py @@ -30,11 +30,14 @@ CRM Claims Phone ================ -This module validate phone numbers in the CRM Claim 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 validate phone numbers in the CRM Claim 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. +Please contact Alexis de Lattre from Akretion +for any help or question about this module. """, 'author': 'Akretion', 'website': 'http://www.akretion.com/', diff --git a/crm_phone/__openerp__.py b/crm_phone/__openerp__.py index d0dc77e..8ef34ed 100644 --- a/crm_phone/__openerp__.py +++ b/crm_phone/__openerp__.py @@ -30,11 +30,14 @@ 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 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. +Please contact Alexis de Lattre from Akretion +for any help or question about this module. """, 'author': 'Akretion', 'website': 'http://www.akretion.com/', diff --git a/event_phone/__openerp__.py b/event_phone/__openerp__.py index 1616a2c..33af8a5 100644 --- a/event_phone/__openerp__.py +++ b/event_phone/__openerp__.py @@ -30,11 +30,14 @@ Event Phone =========== -This module validate phone numbers in the Event 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 validate phone numbers in the Event 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. +Please contact Alexis de Lattre from Akretion +for any help or question about this module. """, 'author': 'Akretion', 'website': 'http://www.akretion.com/', diff --git a/hr_phone/__openerp__.py b/hr_phone/__openerp__.py index 753a5da..b5d790c 100644 --- a/hr_phone/__openerp__.py +++ b/hr_phone/__openerp__.py @@ -30,11 +30,14 @@ HR Phone ======== -This module validate phone numbers in the HR 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 validate phone numbers in the HR 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. +Please contact Alexis de Lattre from Akretion +for any help or question about this module. """, 'author': 'Akretion', 'website': 'http://www.akretion.com/', diff --git a/hr_recruitment_phone/__openerp__.py b/hr_recruitment_phone/__openerp__.py index 24d008f..c0d7be9 100644 --- a/hr_recruitment_phone/__openerp__.py +++ b/hr_recruitment_phone/__openerp__.py @@ -30,11 +30,14 @@ HR Recruitment Phone ==================== -This module validate phone numbers in the HR Recruitment 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 validate phone numbers in the HR Recruitment 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. +Please contact Alexis de Lattre from Akretion +for any help or question about this module. """, 'author': 'Akretion', 'website': 'http://www.akretion.com/',