[已解决]TypeError: __init__() takes exactly 2 arguments (3 given)
-
这个在raise ValidationError时报错的?哪里的问题啊?
2018-05-11 06:31:42,013 16180 DEBUG bcp_v10 odoo.http.rpc.request: call_kw: import.wizard search_read: time:0.004s mem: 1184660k -> 1184660k (diff: 0k) 2018-05-11 06:31:42,014 16180 INFO bcp_v10 werkzeug: 127.0.0.1 - - [11/May/2018 06:31:42] "POST /web/dataset/call_kw/import.wizard/search_read HTTP/1.1" 200 - 2018-05-11 06:31:42,026 16180 DEBUG bcp_v10 odoo.api: call import.wizard(89,).import_eco() 2018-05-11 06:31:42,070 16180 ERROR bcp_v10 odoo.http: Exception during JSON request handling. Traceback (most recent call last): File "/home/hui/odoo-dev/odoo10/odoo/odoo/http.py", line 640, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/home/hui/odoo-dev/odoo10/odoo/odoo/http.py", line 677, in dispatch result = self._call_function(**self.params) File "/home/hui/odoo-dev/odoo10/odoo/odoo/http.py", line 333, in _call_function return checked_call(self.db, *args, **kwargs) File "/home/hui/odoo-dev/odoo10/odoo/odoo/service/model.py", line 101, in wrapper return f(dbname, *args, **kwargs) File "/home/hui/odoo-dev/odoo10/odoo/odoo/http.py", line 326, in checked_call result = self.endpoint(*a, **kw) File "/home/hui/odoo-dev/odoo10/odoo/odoo/http.py", line 935, in __call__ return self.method(*args, **kw) File "/home/hui/odoo-dev/odoo10/odoo/odoo/http.py", line 506, in response_wrap response = f(*args, **kw) File "/home/hui/odoo-dev/odoo10/odoo/addons/web/controllers/main.py", line 889, in call_button action = self._call_kw(model, method, args, {}) File "/home/hui/odoo-dev/odoo10/odoo/addons/web/controllers/main.py", line 877, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/home/hui/odoo-dev/odoo10/odoo/odoo/api.py", line 689, in call_kw return call_kw_multi(method, model, args, kwargs) File "/home/hui/odoo-dev/odoo10/odoo/odoo/api.py", line 680, in call_kw_multi result = method(recs, *args, **kwargs) File "/home/hui/odoo-dev/odoo10/abbsps/sps_eco/wizard/import_wizard_eco.py", line 169, in import_eco return_info = self.handel_eco_data(i, val_eco, val_line) File "/home/hui/odoo-dev/odoo10/abbsps/sps_eco/wizard/import_wizard_eco.py", line 217, in handel_eco_data raise ValidationError('There is no user named %s in row %s.', (responsible, str(i))) TypeError: __init__() takes exactly 2 arguments (3 given) 2018-05-11 06:31:42,077 16180 INFO bcp_v10 werkzeug: 127.0.0.1 - - [11/May/2018 06:31:42] "POST /web/dataset/call_button HTTP/1.1" 200 - 2018-05-11 06:31:42,084 16180 DEBUG bcp_v10 odoo.api: call import.wizard().search_read([[u'id', u'in', [89]]], [u'state', u'data', u'display_name', u'__last_update']) 2018-05-11 06:31:42,090 16180 DEBUG bcp_v10 odoo.http.rpc.request: call_kw: import.wizard search_read: time:0.006s mem: 1185172k -> 1185172k (diff: 0k) 2018-05-11 06:31:42,091 16180 INFO bcp_v10 werkzeug: 127.0.0.1 - - [11/May/2018 06:31:42] "POST /web/dataset/call_kw/import.wizard/search_read HTTP/1.1" 200 -
-
ValidationError
类实例化只接受2个参数(self和error_message),你给多了,将raise ValidationError
如下修改一下:raise ValidationError('There is no user named {} in row {}.'.format(responsible, str(i)))
-
@digitalsatori
是一个参数的话,可以直接像我报错的那样写,如果多个参数的话就要像你这样写了,或者我下面写的也可以。犯了一个不难的错,我还没找到问题,:face_with_tears_of_joy:raise ValidationError('There is no user named %s in row %s.' % (responsible, str(i)))
-
@digitalsatori
是一个参数的话,可以直接像我报错的那样写,如果多个参数的话就要像你这样写了,或者我下面写的也可以。犯了一个不难的错,我还没找到问题,:face_with_tears_of_joy:raise ValidationError('There is no user named %s in row %s.' % (responsible, str(i)))