Browse Source

Replace narrow_no_break_space by no_break_space to make it work on mac OS X

pull/88/head
Alexis de Lattre 9 years ago
parent
commit
8dbdc93517
  1. 7
      base_phone/fields.py
  2. 5
      base_phone/static/src/js/phone_widget.js

7
base_phone/fields.py

@ -45,8 +45,8 @@ class Phone(fields.Char):
res_parse = phonenumbers.parse(res) res_parse = phonenumbers.parse(res)
res = phonenumbers.format_number( res = phonenumbers.format_number(
res_parse, phonenumbers.PhoneNumberFormat.INTERNATIONAL) res_parse, phonenumbers.PhoneNumberFormat.INTERNATIONAL)
narrow_no_break_space = u'\u202f'
res = res.replace(' ', narrow_no_break_space)
no_break_space = u'\u00A0'
res = res.replace(' ', no_break_space)
except: except:
pass pass
# print 'cache value', res # print 'cache value', res
@ -57,9 +57,6 @@ def convert_phone_field(value, country_code):
_logger.debug( _logger.debug(
'convert_phone_field value=%s country=%s', value, country_code) 'convert_phone_field value=%s country=%s', value, country_code)
try: try:
narrow_no_break_space = u'\u202f'
# phonenumbers.parse fails with narrow_no_break_space
value = value.replace(narrow_no_break_space, '')
res_parse = phonenumbers.parse( res_parse = phonenumbers.parse(
value, country_code) value, country_code)
_logger.debug('res_parse=%s', res_parse) _logger.debug('res_parse=%s', res_parse)

5
base_phone/static/src/js/phone_widget.js

@ -28,7 +28,7 @@ var FieldPhone = formwidgets.FieldChar.extend({
var raw_phone_num = ''; var raw_phone_num = '';
if (phone_num) { if (phone_num) {
// remove non-breaking-space // remove non-breaking-space
raw_phone_num = phone_num.replace(//g, '');
raw_phone_num = phone_num.replace(/ /g, '');
raw_phone_num = raw_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); this.$el.find('a.oe_form_uri').attr('href', 'tel:' + raw_phone_num).text(phone_num);
} }
@ -101,7 +101,8 @@ var FieldFax = formwidgets.FieldChar.extend({
var fax_num = this.get('value'); var fax_num = this.get('value');
// console.log('BASE_PHONE fax_num = %s', fax_num); // console.log('BASE_PHONE fax_num = %s', fax_num);
if (fax_num) { if (fax_num) {
var raw_fax_num = fax_num.replace(/ /g, '');
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); this.$el.find('a').attr('href', 'fax:' + raw_fax_num).text(fax_num);
} }
else { else {

Loading…
Cancel
Save