Browse Source

Restore click2dial feature

pull/88/head
Alexis de Lattre 9 years ago
parent
commit
076e4e2046
  1. 2
      base_phone/models/phone_common.py
  2. 18
      base_phone/static/src/js/phone_widget.js

2
base_phone/models/phone_common.py

@ -126,7 +126,7 @@ class PhoneCommon(models.AbstractModel):
''' '''
assert(erp_number), 'Missing phone number' assert(erp_number), 'Missing phone number'
_logger.debug('Number before reformat = %s' % erp_number) _logger.debug('Number before reformat = %s' % erp_number)
# erp_number are supposed to be in E.164 format, so no need to
# erp_number are supposed to be in International format, so no need to
# give a country code here # give a country code here
parsed_num = phonenumbers.parse(erp_number, None) parsed_num = phonenumbers.parse(erp_number, None)
country_code = self.env.user.company_id.country_id.code country_code = self.env.user.company_id.country_id.code

18
base_phone/static/src/js/phone_widget.js

@ -25,16 +25,18 @@ var FieldPhone = formwidgets.FieldChar.extend({
var self = this; var self = this;
var phone_num = this.get('value'); var phone_num = this.get('value');
// console.log('BASE_PHONE phone_num = %s', phone_num); // console.log('BASE_PHONE phone_num = %s', phone_num);
var raw_phone_num = '';
if (phone_num) { if (phone_num) {
var raw_phone_num = phone_num.replace(/ /g, '');
this.$el.find('a').attr('href', 'tel:' + raw_phone_num).text(phone_num);
// remove non-breaking-space
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').attr('href', '').text('');
this.$el.find('a.oe_form_uri').attr('href', '').text('');
} }
/*
var click2dial_text = ''; var click2dial_text = '';
if (formatted_phone_num && !this.options.dial_button_invisible) {
if (phone_num && !this.options.dial_button_invisible) {
click2dial_text = _t('Dial'); click2dial_text = _t('Dial');
} }
this.$el.find('#click2dial').off('click'); this.$el.find('#click2dial').off('click');
@ -45,7 +47,7 @@ var FieldPhone = formwidgets.FieldChar.extend({
_t('Click2dial started'), _t('Click2dial started'),
_t('Unhook your ringing phone')); _t('Unhook your ringing phone'));
var arg = { var arg = {
'phone_number': phone_num,
'phone_number': raw_phone_num,
'click2dial_model': self.view.dataset.model, 'click2dial_model': self.view.dataset.model,
'click2dial_id': self.view.datarecord.id}; 'click2dial_id': self.view.datarecord.id};
self.rpc('/base_phone/click2dial', arg).done(function(r) { self.rpc('/base_phone/click2dial', arg).done(function(r) {
@ -60,7 +62,7 @@ var FieldPhone = formwidgets.FieldChar.extend({
var context = { var context = {
'click2dial_model': self.view.dataset.model, 'click2dial_model': self.view.dataset.model,
'click2dial_id': self.view.datarecord.id, 'click2dial_id': self.view.datarecord.id,
'phone_number': phone_num,
'phone_number': raw_phone_num,
}; };
var action = { var action = {
name: r.action_name, name: r.action_name,
@ -75,7 +77,7 @@ var FieldPhone = formwidgets.FieldChar.extend({
} }
} }
}); });
}); */
});
} }
}, },
on_button_clicked: function() { on_button_clicked: function() {

Loading…
Cancel
Save