Odoo Help


One2many onchange is not working ODOO 9 TypeError: <openerp.models.NewId object at 0x7f1d3a6d6610> is not JSON serializable

on 11/4/15, 4:06 AM 4,033 views

Can't pass the value to one2many table, this is my code, previous version ODOO 8 this functionality is working but in ODOO 9 it is not working, in where I did a mistake kindly notify that.

My Error message is 
Odoo Server Error
Traceback (most recent call last):
File "/home/sridharan/odoo-20151013/openerp/http.py", line 599, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/sridharan/odoo-20151013/openerp/http.py", line 650, in dispatch
return self._json_response(result)
File "/home/sridharan/odoo-20151013/openerp/http.py", line 588, in _json_response
body = json.dumps(response)
File "/usr/lib/python2.7/json/__init__.py", line 243, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <openerp.models.NewId object at 0x7f1d3a6d6610> is not JSON serializable
Code is here
def onchange_duplicate_supplier(self, cr, uid, ids, name, context=None):
if name == False:
return True
if name != False:
ls = []
supplier_obj = self.pool.get('sample.supplier')
bo_id = supplier_obj.search(cr, uid, [('name','ilike',name)])
for line in supplier_obj.browse(cr, uid, bo_id):
'name' : line.name
return {'value': {'supplier_merge_ids':ls}}        

We getting same issue, one2many on onchange not working. upgrade is hell, working fine for us in older version but 9.0 had issues.

on 1/25/16, 5:23 AM
On 1/25/16, 6:58 AM


def onchange(self, values, field_name, field_onchange):


match = onchange_v7.match(field_onchange[field_name])

if match:

method, params = match.groups()

# evaluate params -> tuple

global_vars = {'context': self._context, 'uid': self._uid}

if self._context.get('field_parent'):

class RawRecord(object):

def __init__(self, record):

self._record = record

def __getattr__(self, name):

field = self._record._fields[name]

value = self._record[name]

return field.convert_to_onchange(value)

record = self[self._context['field_parent']]

global_vars['parent'] = RawRecord(record)

params = eval("[%s]" % params, global_vars, values)

# call onchange method with context when possible

args = (self._cr, self._uid, self._ids) + tuple(params)


method_res = getattr(self._model, method)(*args, context=self._context)

except TypeError:

method_res = getattr(self._model, method)(*args)

return method_res

super(model_name,self).onchange(values, field_name, field_onchange)

except TypeError:

return True


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 11/4/15, 4:06 AM
Seen: 4033 times
Last updated: 5/27/16, 1:40 AM