Hi
I'm having trouble calling the Create method in Python and it's throwing a NameError. The method that calls the Create method is called from JS.
Here is the JS (this works so maybe less important):
this._rpc({
model:'tcx.call.log',
method:'maakTest',
args:[
pId,
pName,
pNumber,
cDuration,
datum,
],
});
This is the Python code:
@api.one
def maakTest(partner_id, other_party_name, other_party_number, duration, call_date_time):
import pdb; pdb.set_trace()
vals = {'partner_id':partner_id,'other_party_name':other_party_name,'other_party_number':other_party_number,'duration':duration,'call_date_time':call_date_time}
self.create(vals)
Here is the error:
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/http.py", line 654, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo/odoo/http.py", line 312, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/opt/odoo/odoo/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/opt/odoo/odoo/odoo/http.py", line 696, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo/odoo/http.py", line 344, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo/odoo/http.py", line 337, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo/odoo/http.py", line 939, in __call__
return self.method(*args, **kw)
File "/opt/odoo/odoo/odoo/http.py", line 517, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo/addons/web/controllers/main.py", line 962, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/opt/odoo/odoo/addons/web/controllers/main.py", line 954, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo/odoo/api.py", line 749, in call_kw
return _call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/odoo/odoo/api.py", line 736, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "</usr/local/lib/python3.6/dist-packages/decorator.py:decorator-gen-132>", line 2, in maakTest
File "/opt/odoo/odoo/odoo/api.py", line 372, in loop
result = [method(rec, *args, **kwargs) for rec in self]
File "/opt/odoo/odoo/odoo/api.py", line 372, in <listcomp>
result = [method(rec, *args, **kwargs) for rec in self]
File "/opt/odoo/odoo/custom_addons/threecx/models/call_log.py", line 27, in maakTest
self.create(vals)
NameError: name 'self' is not definedNow, I do know that I haven't defined 'self' in ths case, but I'm wondering on how to do it. Adding it to the parameter list in the method header and then adding null in JavaScript isn't working and I don't see any other way of calling the create method.
Any help is greatly appreciated!