[FIX] graph view of a new model has a 50% chance to cause an error

This is a copy of https://bugs.launchpad.net/openobject-server/+bug/1316948

I wanted to implement a diagram view for new models of a new module. When I open the diagram view, I get an error (with OpenERP 7.0 rev 5138.5.119, but the same problem appears to be in trunk as well)

Server Traceback (most recent call last):
  File "/home/thomas/openerp/server/openerp/addons/web/session.py", line 89, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/home/thomas/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/thomas/openerp/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/home/thomas/openerp/server/openerp/osv/osv.py", line 190, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/home/thomas/openerp/server/openerp/osv/osv.py", line 132, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/thomas/openerp/server/openerp/osv/osv.py", line 199, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/thomas/openerp/server/openerp/osv/osv.py", line 187, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/thomas/openerp/server/openerp/addons/base/ir/ir_ui_view.py", line 270, in graph_get
    g.process(start)
  File "/home/thomas/openerp/server/openerp/tools/graph.py", line 696, in process
    self.order_in_rank() #Second step: ordering nodes within ranks
  File "/home/thomas/openerp/server/openerp/tools/graph.py", line 658, in order_in_rank
    self.process_order()
  File "/home/thomas/openerp/server/openerp/tools/graph.py", line 533, in process_order
    one_level_el = self.tree_list[self.start][0][1]
IndexError: list index out of range

The problem is caused by the setup in addons/base/ir/ir_ui_view.py in the method graph_get of the view class. The values of '_Source_Field' and '_Destination_Field' are determined by the order of _Node_Obj._columns.items(), which a developer cannot control. If the order happens to be wrong (as in my case, in my ir_model_fields the 'in' field was before the 'out' field), then _Source_Field and _Destination_Field must be switched.