TypeError:_get_category()只需要6个参数(给定4个)

时间:2015-12-18 06:34:23

标签: python openerp

究竟是什么错?

我正在尝试运行代码,但我收到的错误

我附上了追溯。

    Server Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0-20141009-011214\server\openerp\addons\web\session.py", line 89, in send
  File "C:\Program Files (x86)\OpenERP 7.0-20141009-011214\server\.\openerp\netsvc.py", line 296, in dispatch_rpc
  File "C:\Program Files (x86)\OpenERP 7.0-20141009-011214\server\.\openerp\service\web_services.py", line 626, in dispatch
  File "C:\Program Files (x86)\OpenERP 7.0-20141009-011214\server\.\openerp\osv\osv.py", line 190, in execute_kw
  File "C:\Program Files (x86)\OpenERP 7.0-20141009-011214\server\.\openerp\osv\osv.py", line 132, in wrapper
  File "C:\Program Files (x86)\OpenERP 7.0-20141009-011214\server\.\openerp\osv\osv.py", line 199, in execute
  File "C:\Program Files (x86)\OpenERP 7.0-20141009-011214\server\.\openerp\osv\osv.py", line 187, in execute_cr
  File "C:\Program Files (x86)\OpenERP 7.0-20141009-011214\server\.\openerp\osv\orm.py", line 1610, in default_get
TypeError: _get_category() takes at least 6 arguments (4 given)

def _get_category(self, cr, uid, ids, field_names, arg, context=None):
        category_obj = self.pool.get('module.category').browse(cr, uid, category_id)
        return {'value': {'category_id': category_obj.name}}

_name ='module.level'
    _description ="Module Level"
    _columns = {
    'name':fields.char('Level', size=20),
    'category_id':fields.function(_get_category,type='many2one',obj="module.category",method=True,string='Session'),

1 个答案:

答案 0 :(得分:1)

您将错误的参数传递给函数。

尝试使用此代码:

def _get_category(self, cr, uid, ids, field_names, arg, context=None): 
    #function logic
    return