How to convert Odoo/Python code from old to new APIs?
<p>I am convert my whole Odoo Python code from the old API to the new API. So when I create new API this error is generated. How to solve it?</p>

<pre><code>File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 380, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python2.7/dist-packages/simplejson/encoder.py", line 275, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python2.7/dist-packages/simplejson/encoder.py", line 357, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python2.7/dist-packages/simplejson/encoder.py", line 252, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: flight.itinerary(18,) is not JSON serializable
</code></pre>

<p>Somewhere in your code you are passing an object ( flight.itinerary(18,) ) you probably are assigning a value like this.</p>

<pre><code>flight_itinerary = self.env['flight.itinerary'].browse([18])

something_else = flight_itinerary
</code></pre>

<p>Try </p>

<pre><code>something_else = flight_itinerary.id
</code></pre>

<p>My guess is you are passing a flight.itinerary object when you mean to pass the id </p>

python openerp odoo-8