odoo/odoo — pull request #551 by mcojocaru (2014-06-16 09:04:36+00:00)
Title: Fix for issue #545

In teh steps to reproduce for issue #545, i mentioned that crm_phonecall_view.xml should be changed as below.

```
crm_phonecall_view.xml

CRM - Phone Calls Calendar
crm.phonecall

```

Consider the following call stack trace and notice the breakpoint at line 646 for in the http.py file, proxy() method:
```
/home/marcel/openerp/saas-3/odoo/addons/web/controllers/main.py(1233)call_kw()
1231 @http.route(['/web/dataset/call_kw', '/web/dataset/call_kw/'], type='json', auth="user")
1232 def call_kw(self, model, method, args, kwargs, path=None):
-> 1233 return self._call_kw(model, method, args, kwargs)
1234

/home/marcel/openerp/saas-3/odoo/addons/web/controllers/main.py(1216)_call_kw()
1214 names = dict(request.session.model(model).name_search('', args[0], **kwargs))
1215 args[1].remove('display_name')
-> 1216 records = getattr(request.session.model(model), method)(*args, **kwargs)
1217 for record in records:

/home/marcel/openerp/saas-3/odoo/openerp/http.py(647)proxy()
644 if method == "read":
645 if isinstance(result, list) and len(result) > 0 and "id" in result[0]:
646 import ipdb; ipdb.set_trace()
--> 647 index = {}
648 for r in result:
649 index[r['id']] = r
650 result = [index[x] for x in args[0] if x in index]
651 return result
652 return proxy
```

Notice below the values for args and result variables when reaching line 647 above.

```
ipdb> print args
args = (['2'], ['message_follower_ids', 'duration', 'partner_id', 'message_ids', 'user_id', 'priority', 'state', 'opportunity_id', 'description', 'section_id', 'partner_mobile', 'date', 'categ_id', 'name', 'partner_phone'])
----------------
ipdb> print result
[{'message_follower_ids': [3], 'user_id': (1, u'Administrator'), 'description': False, 'categ_id': False, 'section_id': False, 'name': u'teeeest', 'priority': u'3', 'date': '2014-06-14 07:00:00', 'state': u'open', 'partner_mobile': False, 'duration': 0.25, 'message_ids': [11], 'partner_id': False, 'id': 2, 'partner_phone': False, 'opportunity_id': False}]
```

The reason for the empty popup when click an event in CRM/Schedule Calls -- Calendar View, is that the args touple should have [2] instead of ['2'] at the first position.

At line 650, index = {2: {....whatever... }} and x is '2'. Therefore result = [], which will cause the empty popup window.

By applying this patch, the values for args and result will be the following:

```
ipdb> print args
args = ([2], ['message_follower_ids', 'duration', 'partner_id', 'message_ids', 'user_id', 'priority', 'state', 'opportunity_id', 'description', 'section_id', 'partner_mobile', 'date', 'categ_id', 'name', 'partner_phone'])
kw = {'context': {'lang': 'en_US', 'default_state': 'open', 'uid': 1, 'bin_size': True, 'params': {'action': 144, 'model': 'crm.phonecall', '_push_me': False, 'view_type': 'calendar'}, 'tz': False, 'future_display_name': True}}

ipdb> print result
[{'message_follower_ids': [3], 'user_id': (1, u'Administrator'), 'description': False, 'categ_id': False, 'section_id': False, 'name': u'teeeest', 'priority': u'3', 'date': '2014-06-14 07:00:00', 'state': u'open', 'partner_mobile': False, 'duration': 0.25, 'message_ids': [11], 'partner_id': False, 'id': 2, 'partner_phone': False, 'opportunity_id': False}]
```

Notice args[0] = [2] and not ['2'] like before. Therefore the result variable will not be empty.