From d0a008beb928e9e58f85acd43f3ad7db7712d82e Mon Sep 17 00:00:00 2001
From: nodenet-1 <>
Date: Tue, 5 Jun 2012 23:27:42 +0200
Subject: [PATCH] Patch courtesy of daemon dog : - add support for SCCP phones
- adds dial_suffix to allow some tweaking for SCCP phones - move menu entry
of asterisk servers to Settings >Configuration > Asterisk servers - strip (0)
from phone number in all scenarios
Added by me : re-org of res.users form view, to separate standard parameters from advanced/optional ones.
---
asterisk_click2dial/__openerp__.py | 2 +-
asterisk_click2dial/asterisk_click2dial.py | 9 ++++++++-
asterisk_click2dial/asterisk_server_view.xml | 5 +++--
asterisk_click2dial/res_users_view.xml | 5 ++++-
asterisk_click2dial_crm/res_users_view.xml | 2 +-
5 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/asterisk_click2dial/__openerp__.py b/asterisk_click2dial/__openerp__.py
index 37241bb..d49e8c1 100644
--- a/asterisk_click2dial/__openerp__.py
+++ b/asterisk_click2dial/__openerp__.py
@@ -22,7 +22,7 @@
{
'name': 'Asterisk Click2dial',
- 'version': '0.3',
+ 'version': '0.4',
'category': 'Extra Tools',
'license': 'AGPL-3',
'description': """This module adds 3 functionnalities :
diff --git a/asterisk_click2dial/asterisk_click2dial.py b/asterisk_click2dial/asterisk_click2dial.py
index 4d8cee4..1db31f5 100644
--- a/asterisk_click2dial/asterisk_click2dial.py
+++ b/asterisk_click2dial/asterisk_click2dial.py
@@ -120,6 +120,10 @@ class asterisk_server(osv.osv):
if not tmp_number:
raise osv.except_osv(error_title_msg, invalid_format_msg)
+ # treat (0) as a special condition as we dont want an extra 0 to be inserted in the number
+ # FIXME all 0s after the country prefix should be stripped off
+ tmp_number = tmp_number.replace('(0)','')
+
# First, we remove all stupid caracters and spaces
for char_to_remove in [' ', '.', '(', ')', '[', ']', '-', '/']:
tmp_number = tmp_number.replace(char_to_remove, '')
@@ -275,7 +279,7 @@ class asterisk_server(osv.osv):
# Dial with Asterisk
originate_act = 'Action: originate\r\n' + \
- 'Channel: ' + user.asterisk_chan_type + '/' + user.internal_number + '\r\n' + \
+ 'Channel: ' + user.asterisk_chan_type + '/' + user.internal_number + ( ('/' + user.dial_suffix) if user.dial_suffix else '') + '\r\n' + \
'Priority: ' + str(ast_server.extension_priority) + '\r\n' + \
'Timeout: ' + str(ast_server.wait_time*1000) + '\r\n' + \
'CallerId: ' + user.callerid + '\r\n' + \
@@ -359,6 +363,8 @@ class res_users(osv.osv):
_columns = {
'internal_number': fields.char('Internal number', size=15,
help="User's internal phone number."),
+ 'dial_suffix': fields.char('User-specific dial suffix', size=15,
+ help="User-specific dial suffix such as aa=2wb for SCCP auto answer."),
'callerid': fields.char('Caller ID', size=50,
help="Caller ID used for the calls initiated by this user."),
# You'd probably think : Asterisk should reuse the callerID of sip.conf !
@@ -372,6 +378,7 @@ class res_users(osv.osv):
('MGCP', 'MGCP'),
('mISDN', 'mISDN'),
('H323', 'H323'),
+ ('SCCP', 'SCCP'),
], 'Asterisk channel type',
help="Asterisk channel type, as used in the Asterisk dialplan. If the user has a regular IP phone, the channel type is 'SIP'."),
'alert_info': fields.char('User-specific Alert-Info SIP header', size=255, help="Set a user-specific 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. If you want to have several variable headers, separate them with '|'."),
diff --git a/asterisk_click2dial/asterisk_server_view.xml b/asterisk_click2dial/asterisk_server_view.xml
index 667b0c3..c61e210 100644
--- a/asterisk_click2dial/asterisk_server_view.xml
+++ b/asterisk_click2dial/asterisk_server_view.xml
@@ -75,8 +75,9 @@
{'asterisk_server_main_view': True}
-
-
+
+
+
diff --git a/asterisk_click2dial/res_users_view.xml b/asterisk_click2dial/res_users_view.xml
index 4e036d7..c656d83 100644
--- a/asterisk_click2dial/res_users_view.xml
+++ b/asterisk_click2dial/res_users_view.xml
@@ -17,12 +17,15 @@
+
+
+
+
-
diff --git a/asterisk_click2dial_crm/res_users_view.xml b/asterisk_click2dial_crm/res_users_view.xml
index d7b0f7c..351d3ca 100644
--- a/asterisk_click2dial_crm/res_users_view.xml
+++ b/asterisk_click2dial_crm/res_users_view.xml
@@ -14,7 +14,7 @@
res.users
-
+