考虑这种方法:
@api.multi
def new_open_window(list_ids, xml_id, module):
""" Generate new window at view form or tree """
action = self.env.ref("{}.{}".format(module, xml_id))
result = action.read()[0]
if isinstance(list_ids, (list, tuple)):
result['domain'] = [('id', 'in', list_ids)]
else:
result['res_id'] = list_ids
return result
此方法由以下方法调用:
@api.multi
def create_invoice(self):
""" Create a invoice refund
"""
#context = context or {}
wizard_brw = self.browse()
inv_id = self._context.get('active_id')
for wizard in wizard_brw:
if not wizard.sure:
raise UserError(
_("Validation error!"),
_("Please confirm that you know what you're doing by"
" checking the option bellow!"))
if (wizard.invoice_id and wizard.invoice_id.company_id.jour_id and
wizard.invoice_id and wizard.invoice_id.company_id.acc_id):
inv_id = self.action_invoice_create(wizard,
wizard.invoice_id)
else:
raise UserError(
_('Validation error!'),
_("You must go to the company form and configure a journal"
" and an account for damaged invoices"))
return self.new_open_window([inv_id], 'action_invoice_tree1', 'account')
点击create_invoice
按钮/方法后,它会抛出这个:
Traceback (most recent call last):
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 638, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 675, in dispatch
result = self._call_function(**self.params)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 331, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/service/model.py", line 119, in wrapper
return f(dbname, *args, **kwargs)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 324, in checked_call
result = self.endpoint(*a, **kw)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 933, in __call__
return self.method(*args, **kw)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 504, in response_wrap
response = f(*args, **kw)
File "/home/kristian/odoov10/odoo-10.0rc1c-20161005/odoo/addons/web/controllers/main.py", line 866, in call_button
action = self._call_kw(model, method, args, {})
File "/home/kristian/odoov10/odoo-10.0rc1c-20161005/odoo/addons/web/controllers/main.py", line 854, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/api.py", line 681, in call_kw
return call_kw_multi(method, model, args, kwargs)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/api.py", line 672, in call_kw_multi
result = method(recs, *args, **kwargs)
File "/home/kristian/odoov10/gilda/l10n_ve_fiscal_requirements/wizard/wizard_invoice_nro_ctrl.py", line 138, in create_invoice
return self.new_open_window(inv_id, 'action_invoice_tree1', 'account')
TypeError: new_open_window() takes exactly 3 arguments (4 given)
所以,因为它使用了@api.multi
并且它是一个从按钮调用的方法,我不知道问题的一部分是否缺少self.ensure_one()
,但我猜它不是,或者不仅仅是那个。
有什么想法吗?
答案 0 :(得分:2)
替换:
def new_open_window(list_ids, xml_id, module):
by:
def new_open_window(self, list_ids, xml_id, module):