The number of digits to match from the end of the phone number is now configurable. This code is now fully located in the asterisk_click2dial module (removed from the "get_cid_name.py" script).
WARNING : if you upgrade your asterisk_click2dial module to this version, you should also update the script "get_cid_name.py" on your Asterisk server to this version.
The imports now use the new openerp paths.
Convert self.pool.get('obj') to self.pool['obj'] so that it crashes exactly where it should.
# Lib for phone number reformating -> pip install phonenumbers
importphonenumbers
# Lib py-asterisk from http://code.google.com/p/py-asterisk/
@ -52,6 +52,7 @@ class asterisk_server(osv.osv):
'wait_time':fields.integer('Wait time (sec)',required=True,help="Amount of time (in seconds) Asterisk will try to reach the user's phone before hanging up."),
'extension_priority':fields.integer('Extension priority',required=True,help="Priority of the extension in the Asterisk dialplan. Refer to /etc/asterisk/extensions.conf on your Asterisk server."),
'alert_info':fields.char('Alert-Info SIP header',size=255,help="Set Alert-Info header in SIP request to user's IP Phone for the click2dial feature. If empty, the Alert-Info header will not be added. You can use it to have a special ring tone for click2dial (a silent one !) or to activate auto-answer for example."),
'number_of_digits_to_match_from_end':fields.integer('Number of digits to match from end',help='In several situations, the Asterisk-OpenERP connector will have to find a Partner in OpenERP from a phone number presented by the calling party. As the phone numbers presented by your phone operator may not always be displayed in a standard format, the best method to find the related Partner in OpenERP is to try to match the end of the phone numbers of the Partners in OpenERP with the N last digits of the phone number presented by the calling party. N is the value you should enter in this field.'),
'company_id':fields.many2one('res.company','Company',help="Company who uses the Asterisk server."),
}
@ -63,6 +64,7 @@ class asterisk_server(osv.osv):
'international_prefix':'00',
'extension_priority':1,
'wait_time':15,
'number_of_digits_to_match_from_end':9,
}
def_check_validity(self,cr,uid,ids):
@ -84,7 +86,9 @@ class asterisk_server(osv.osv):
ifserver.extension_priority<1:
raiseosv.except_osv(_('Error :'),_("The 'extension priority' must be a positive value for the Asterisk server '%s'"%server.name))
ifserver.port>65535orserver.port<1:
raiseosv.except_osv(_('Error :'),_("You should set a TCP port between 1 and 65535 for the Asterik server '%s'"%server.name))
raiseosv.except_osv(_('Error :'),_("You should set a TCP port between 1 and 65535 for the Asterisk server '%s'"%server.name))
(_check_validity,"Error message in raise",['out_prefix','country_prefix','national_prefix','international_prefix','wait_time','extension_priority','port','context','alert_info','login','password']),
(_check_validity,"Error message in raise",['out_prefix','country_prefix','national_prefix','international_prefix','wait_time','extension_priority','port','context','alert_info','login','password','number_of_digits_to_match_from_end']),
]
@ -175,9 +179,10 @@ class asterisk_server(osv.osv):
raiseosv.except_osv(_('Error :'),_('There is no phone number !'))
eliferp_number_displayandnoterp_number_e164:
raiseosv.except_osv(_('Error :'),_("The phone number isn't stored in the standard E.164 format. Try to run the wizard 'Reformat all phone numbers' from the menu Settings > Configuration > Asterisk."))
raiseosv.except_osv(_('Error :'),_("The object '%s' is not found in your OpenERP database, probably because the related module is not installed."%oerp_object._description))