Hi,
i tried to create an object from an onchange-method. The problem is, that i get following error, after creating the object:
Traceback (most recent call last):
File "/home/odoo/odoo/openerp/http.py", line 500, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/odoo/odoo/openerp/http.py", line 517, in dispatch
result = self._call_function(**self.params)
File "/home/odoo/odoo/openerp/http.py", line 283, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/odoo/odoo/openerp/service/model.py", line 113, in wrapper
return f(dbname, *args, **kwargs)
File "/home/odoo/odoo/openerp/http.py", line 280, in checked_call
return self.endpoint(*a, **kw)
File "/home/odoo/odoo/openerp/http.py", line 733, in __call__
return self.method(*args, **kw)
File "/home/odoo/odoo/openerp/http.py", line 376, in response_wrap
response = f(*args, **kw)
File "/home/odoo/odoo/addons/web/controllers/main.py", line 944, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/home/odoo/odoo/addons/web/controllers/main.py", line 936, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/home/odoo/odoo/openerp/api.py", line 237, in wrapper
return old_api(self, *args, **kwargs)
File "/home/odoo/odoo/openerp/api.py", line 360, in old_api
result = method(recs, *args, **kwargs)
File "/home/odoo/odoo/openerp/models.py", line 5718, in onchange
record._onchange_eval(name, field_onchange[name], result)
File "/home/odoo/odoo/openerp/models.py", line 5648, in _onchange_eval
params = eval("[%s]" % params, global_vars, field_vars)
File "/home/odoo/odoo/openerp/tools/safe_eval.py", line 313, in safe_eval
return eval(c, globals_dict, locals_dict)
File "", line 1, in <module>
ValueError: "name 'parent_id' is not defined" while evaluating
'[use_parent_address, parent_id]'
Here is the code line which provide the object creation:
vals = {
'list_id':list_id,
'email':email,
'partner_id':partner_id,
'name': name,
}
self.pool['mail.mass_mailing.contact'].create(cr, uid, vals, context=context)
Can someone give me a hint how to fix that?
Hi Damien Bouvy, ty for this answer. Unlikely i have no Karma to comment your answer, but i voted for it =) So first ty for the hint. I waived to put all this into an onchange function. Now i got my solution with the write() method. The aim was to manage the marketinglists from the customer form^^