Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

TypeError: _get_category() takes exactly 6 arguments (4 given)

By
supreeth
on 12/18/15, 1:50 AM 413 views

What exactly is Wrong?

I am trying to run the code and i am getting below error:

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_name, 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
Ajay Patel
On 12/18/15, 2:00 AM

functional field have 7 argument with self, and context, 

and use ids as a category_id

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

@ajay No, same issue. i have edit my question with traceback

supreeth
on 12/18/15, 2:05 AM

@supreeth you replace your function with this??

Ajay Patel
on 12/18/15, 2:11 AM

@ajay Yes

supreeth
on 12/18/15, 2:12 AM

@supreeth give me traceback after replace function.

Ajay Patel
on 12/18/15, 2:21 AM

@ajay i posted

supreeth
on 12/18/15, 2:26 AM

@supreeth its working for my side, check if you have problem to extend osv or import lib

Ajay Patel
on 12/18/15, 3:29 AM

@ajay Thank yo, it is working fine now. I had called that function in _default so it was throwing error. Working fine now

supreeth
on 12/18/15, 3:57 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/18/15, 1:50 AM
Seen: 413 times
Last updated: 12/18/15, 4:06 AM