Can't get calling number from Asterisk.

Bug #1170058 reported by Balaji Kannan
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
OpenERP-Asterisk connector
New
Undecided
Unassigned

Bug Description

I am using asterisk_click2dial and asterisk_click2dial_crm module on OpenERP 7.0. Dialing the customer works fine. However, when doing the Open Calling Partner, I get the following error:

Error :

Can't get calling number from Asterisk.
Here is the error: '__init__() takes exactly 2 arguments (1 given)'

The error is reported on line 292 of asterisk_click2deal.py. My guess is that it is happening at

list_chan = ast_manager.Status() call. (line:275) in the try-except block.

Bazaar branch: 7.0 (lp:openerp-asterisk-connector)
Revision: 76 / 80
py_Asterisk version 0.5.1

Revision history for this message
invitu (invitu) wrote :

check your setup in /etc/asterisk/manager.conf
write = reporting,originate

Revision history for this message
Balaji Kannan (bkannan) wrote :

After the change suggested, the error shown is as follows:

Error :

Can't get calling number from Asterisk.
Here is the error: 'argument of type 'NoneType' is not iterable'

Revision history for this message
Marcel van der Boom (HS-Development BV) (mrb) wrote :

From the original bug report it is not entirely clear *when* you click on 'Open Calling Partner' Are you pressing it on an /outgoing/ call you made or an /incoming/ call?

Assuming an /incoming/ call, the status information that is parsed can be different between different deployments of Asterisk. It might help to have that status information (it gets logged in the server log at debug level, look for lines: "Result of Status AMI request")

Revision history for this message
Clemens Rambow (openbig.org) (c-rambow) wrote :
Download full text (3.3 KiB)

I'm having the same issue as mentioned in comment #2. The issue occurs on incoming calls when clicking "open calling partner" while the phone is still ringing - the OpenERP debug log says following (I replaced the sensitive data with 'X' chars):

2013-06-19 15:34:23,116 5471 DEBUG ? openerp.addons.asterisk_click2dial.asterisk_click2dial: Call get_name_from_phone_number with number = XXXXXXXXX
2013-06-19 15:34:23,127 5471 DEBUG ? openerp.addons.asterisk_click2dial.asterisk_click2dial: Answer get_partner_from_phone_number with name = XXXXXX
2013-06-19 15:34:28,051 5471 DEBUG ? openerp.addons.asterisk_click2dial.asterisk_click2dial: User's phone : SIP/XXXXXX
2013-06-19 15:34:28,053 5471 DEBUG ? openerp.addons.asterisk_click2dial.asterisk_click2dial: Asterisk server = 192.168.XXX.XXX:5038
2013-06-19 15:34:28,108 5471 DEBUG ? openerp.addons.asterisk_click2dial.asterisk_click2dial: Result of Status AMI request: {<Asterisk.Manager.BaseChannel referencing channel 'SIP/XX-XXXXXXXX' of <Asterisk.Manager.Manager connected as openerp to 192.168.XXX.XXX:5038>>: {'ConnectedLineNum': 'XXXXXXXXX', 'Account': 'XXXXXXX', 'CallerIDNum': 'XXXXXXXXXX', 'State': 'Ringing', 'ConnectedLineName': 'XXXXX', 'Uniqueid': 'XXXXXXX.XX', 'CallerIDName': 'XXXXX', 'Privilege': 'Call'}, <Asterisk.Manager.BaseChannel referencing channel 'DAHDI/i2/XXXXXXXXXXXX-1' of <Asterisk.Manager.Manager connected as openerp to 192.168.XXX.XXX:5038>>: {'BridgedChannel': 'SIP/XX-XXXXXXX', 'ConnectedLineNum': 'XXXXXXXXXX', 'Account': 'XXXXXXXXX', 'CallerIDNum': '<unknown>', 'State': 'Up', 'ConnectedLineName': 'XXXXXX XXXXXX', 'Uniqueid': 'XXXXXXXXX.XX', 'CallerIDName': '<unknown>', 'Privilege': 'Call', 'BridgedUniqueid': 'XXXXXXXXX.XX'}, <Asterisk.Manager.BaseChannel referencing channel 'SIP/XX-XXXXXXXXX' of <Asterisk.Manager.Manager connected as openerp to 192.168.XXX.XXX:5038>>: {'BridgedChannel': 'DAHDI/i2/XXXXXXXXXX-1', 'ConnectedLineNum': '<unknown>', 'Context': 'ISDN-PROVIDER-XXXXXXXXXXXXXXXXX', 'Extension': 'DEFAULTPROVIDER', 'Accountcode': 'XXXXXXX', 'ChannelState': '6', 'CallerIDNum': 'XXXXXXXXXX', 'Priority': '5', 'Seconds': '2841', 'ConnectedLineName': '<unknown>', 'Uniqueid': 'XXXXXXXXX.XX', 'CallerIDName': 'XXXXX XXXXXXXX', 'Privilege': 'Call', 'ChannelStateDesc': 'Up', 'BridgedUniqueid': 'XXXXXXXXXX.XX'}, <Asterisk.Manager.BaseChannel referencing channel 'DAHDI/i2/XXXXXXXXXXXXX-5' of <Asterisk.Manager.Manager connected as openerp to 192.168.XXX.XXX:5038>>: {'ConnectedLineNum': '13', 'Context': 'macro-main', 'Extension': 's', 'Accountcode': 'XXXXXXXXX', 'ChannelState': '6', 'CallerIDNum': 'XXXXXXXXXX', 'Priority': '6', 'Seconds': '8', 'ConnectedLineName': 'XXXXX XXXXXXXX', 'Uniqueid': 'XXXXXXXX.XX', 'CallerIDName': 'XXXXX', 'Privilege': 'Call', 'ChannelStateDesc': 'Up'}}
2013-06-19 15:34:28,109 5471 ERROR ? openerp.addons.asterisk_click2dial.asterisk_click2dial: Error in the Status request to Asterisk server 192.168.XXX.XXX
2013-06-19 15:34:28,110 5471 ERROR ? openerp.addons.asterisk_click2dial.asterisk_click2dial: Here is the detail of the error : 'argument of type 'NoneType' is not iterable'
2013-06-19 15:34:28,153 5471 ERROR ? openerp.netsvc: Fehler :
Can't get calling number ...

Read more...

Revision history for this message
Clemens Rambow (openbig.org) (c-rambow) wrote :

I investigated a little more and discovered that the code where it fails with "argument of type 'NoneType' is not iterable" is the following on line 285:
>> if chan.get('ChannelState') == '6' and sip_account in chan.get('BridgedChannel'): # 6 = Up

Perhaps it's related to our specific setup using ISDN/DAHDI , but when I looked exactly where the issue surfaced, I discovered the dictionary in "chan" didn't contain any "BridgedChannel" leading to the mentioned exception to raise.
I have created a patch which resolves the issue for me (by first checking 'ConnectedLineNum' instead 'BridgedChannel'), but I'm not sure if it's a solution which works in general and everywhere.

Revision history for this message
Marcel van der Boom (HS-Development BV) (mrb) wrote :
Revision history for this message
Clemens Rambow (openbig.org) (c-rambow) wrote :

Thanks for pointing me there, Marcel. That would indeed fix the exception.
But in my scenario it would also lead to no calling number being retrieved at all - which is an independent (probably ISDN/DAHDI instead SIP related) issue i guess.

As a workaround I just replaced:
if chan.get('ChannelState') == '6' and sip_account in chan.get('BridgedChannel'): # 6 = Up

with:
if chan.get('ChannelState') == '6' and (chan.get('ConnectedLineNum') == user.internal_number or sip_account in chan.get('BridgedChannel')): # 6 = Up

So the if statement is true before evaluating 'sip_account in chan.get('BridgedChannel')', leading to the correct phone number being returned. As I see now, your fix should also be integrated, as the exception can nevertheless still occur with other responses from asterisk.

Revision history for this message
Alexis de Lattre (alexis-via) wrote :

@Clemens Rambow:

Which version of Asterisk do you have ?

Revision history for this message
Boujraf Youssef (yboujraf) wrote :
Download full text (3.3 KiB)

Dear,

I am working with OdOO V8

When I trying to call, we get this error : "__init__() takes exactly 2 arguments (1 given)"

In the log file we get this :

2014-11-15 00:58:32,102 9349 INFO by-demo werkzeug: 192.168.0.160 - - [15/Nov/2014 00:58:32] "POST /web/menu/load_needaction HTTP/1.1" 200 -
2014-11-15 00:58:35,274 9349 ERROR by-demo openerp.http: Exception during JSON request handling.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 500, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 517, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 283, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 280, in checked_call
    return self.endpoint(*a, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 733, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 376, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 952, in call_button
    action = self._call_kw(model, method, args, {})
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 940, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 237, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 450, in button_immediate_install
    return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 237, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 494, in _button_immediate_function
    function(cr, uid, ids, context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 237, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 417, in button_install
    self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 237, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 360, in old_api
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 396, in state_update
    raise orm.except_orm(_('Error'), _("You try to install module '%s' that depends on module '%s'.\nBut the latter module is not available in your system.") % (module.name, dep.name,))
except_orm: (u'Error', u"You try to inst...

Read more...

Revision history for this message
Alexis de Lattre (alexis-via) wrote :

@Youssef

The solution for your problem is in the error message:

You try to install module 'base_phone_popup' that depends on module 'web_action_request'. But the latter module is not available in your system.

You should get the code of the asterisk connector from github now.
The code of the module web_action_request must be taken from http://bitbucket.org/anybox, see the description of the module base_phone_popup.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.