Browse Source

Use =like instead of like in phone number search, because I add the '%' myself

Add logger.error in the function used by the inherit of write/create, for easier debugging when it is called by a webservice
Add . in PATH in my sample shell scripts
Code cleanup (thank you flake8 !)
pull/8/head
Alexis de Lattre 10 years ago
parent
commit
53c1ff455b
  1. 2
      asterisk_click2dial/scripts/set_name_incoming_timeout.sh
  2. 2
      asterisk_click2dial/scripts/set_name_outgoing_timeout.sh
  3. 10
      base_phone/base_phone.py
  4. 5
      base_phone/wizard/number_not_found.py
  5. 1
      crm_phone/wizard/number_not_found.py

2
asterisk_click2dial/scripts/set_name_incoming_timeout.sh

@ -27,6 +27,6 @@
# echo "agi_callerid:0141401242"|set_name_incoming_timeout.sh
# where 0141401242 is a phone number that could be presented by the calling party
PATH=/usr/local/sbin:/usr/local/bin:/var/lib/asterisk/agi-bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/share/asterisk/agi-bin
PATH=/usr/local/sbin:/usr/local/bin:/var/lib/asterisk/agi-bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/share/asterisk/agi-bin:.
timeout 2s set_name_agi.py --server openerp.mycompany.com --database erp_prod --user-id 12 --password "thepasswd" --geoloc --geoloc-country "FR" --geoloc-lang "fr"

2
asterisk_click2dial/scripts/set_name_outgoing_timeout.sh

@ -27,6 +27,6 @@
# echo "agi_extension:0141401242"|set_name_outgoing_timeout.sh
# where 0141401242 is a phone number that could be presented by the calling party
PATH=/usr/local/sbin:/usr/local/bin:/var/lib/asterisk/agi-bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/share/asterisk/agi-bin
PATH=/usr/local/sbin:/usr/local/bin:/var/lib/asterisk/agi-bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/share/asterisk/agi-bin:.
timeout 2s set_name_agi.py --server openerp.mycompany.com --database erp_prod --user-id 12 --password "thepasswd" --outgoing --outgoing-agi-variable extension

10
base_phone/base_phone.py

@ -90,6 +90,14 @@ class phone_common(orm.AbstractModel):
res_parse = phonenumbers.parse(
vals.get(field), user_countrycode)
except Exception, e:
# I do BOTH logger and raise, because:
# raise is usefull when the record is created/written
# by a user via the Web interface
# logger is usefull when the record is created/written
# via the webservices
_logger.error(
"Cannot reformat the phone number %s to "
"international format" % vals.get(field))
raise orm.except_orm(
_('Error:'),
_("Cannot reformat the phone number '%s' to "
@ -164,7 +172,7 @@ class phone_common(orm.AbstractModel):
% (objname, end_number_to_match))
domain = []
for phonefield in phonefields:
domain.append((phonefield, 'like', pg_search_number))
domain.append((phonefield, '=like', pg_search_number))
if len(phonefields) > 1:
domain = ['|'] * (len(phonefields) - 1) + domain
res_ids = obj.search(cr, uid, domain, context=context)

5
base_phone/wizard/number_not_found.py

@ -55,7 +55,7 @@ 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,9 +76,6 @@ 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)
number_type = phonenumbers.number_type(parsed_num)
context['default_%s' % wiz.number_type] = wiz.e164_number
action = {
'name': _('Create New Partner'),

1
crm_phone/wizard/number_not_found.py

@ -21,7 +21,6 @@
from openerp.osv import orm, fields
from openerp.tools.translate import _
import phonenumbers
class number_not_found(orm.TransientModel):

Loading…
Cancel
Save