Odoo Help

0

TypeError: get_product_provider() takes at most 5 arguments (7 given)

By
Emmanuel Roldan
on 8/11/14, 1:07 PM 5,093 views

I am getting this error: 

Traceback (most recent call last):
  File "C:/GreenOdoo-master-win32/source\openerp\http.py", line 462, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "C:/GreenOdoo-master-win32/source\openerp\http.py", line 481, in dispatch
    result = self._call_function(**self.params)
  File "C:/GreenOdoo-master-win32/source\openerp\http.py", line 297, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "C:/GreenOdoo-master-win32/source\openerp\service\model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "C:/GreenOdoo-master-win32/source\openerp\http.py", line 294, in checked_call
    return self.endpoint(*a, **kw)
  File "C:/GreenOdoo-master-win32/source\openerp\http.py", line 671, in __call__
    return self.method(*args, **kw)
  File "C:/GreenOdoo-master-win32/source\openerp\http.py", line 346, in response_wrap
    response = f(*args, **kw)
  File "C:\GreenOdoo-master-win32\source\addons\web\controllers\main.py", line 1046, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "C:\GreenOdoo-master-win32\source\addons\web\controllers\main.py", line 1038, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "C:/GreenOdoo-master-win32/source\openerp\osv\orm.py", line 4264, in create
    self.pool[model_name]._store_set_values(cr, user, ids, fields2, context)
  File "C:/GreenOdoo-master-win32/source\openerp\osv\orm.py", line 4417, in _store_set_values
    result = self._columns[f].get(cr, self, ids, f, SUPERUSER_ID, context=context)
  File "C:/GreenOdoo-master-win32/source\openerp\osv\fields.py", line 1272, in get
    result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
TypeError: get_product_provider() takes at most 5 arguments (7 given)

Here is my code:

def get_product_provider(self, cr, uid, ids, context=None):
        res = {}
        for record in self.browse(cr, uid, ids, context=context):
            cr.execute('''select id from product_supplierinfo where product_tmpl_id in (select id from product_template) order by RANDOM() limit 1''')
            val = cr.fetchone()
            if val:
                res[record.id] = val[0]
            else:
                res[record.id] = False
            return res

If I change my code to something like this:

def get_product_provider(self, cr, uid, ids, args, field_name, context=None):
        res = {}
        for record in self.browse(cr, uid, ids, context=context):
            cr.execute('''select id from product_supplierinfo where product_tmpl_id in (select id from product_template) order by RANDOM() limit 1''')
            val = cr.fetchone()
            if val:
                res[record.id] = val[0]
            else:
                res[record.id] = False
            return res

I get this error:

Traceback (most recent call last):
  File "C:/GreenOdoo-master-win32/source\openerp\http.py", line 462, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "C:/GreenOdoo-master-win32/source\openerp\http.py", line 481, in dispatch
    result = self._call_function(**self.params)
  File "C:/GreenOdoo-master-win32/source\openerp\http.py", line 297, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "C:/GreenOdoo-master-win32/source\openerp\service\model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "C:/GreenOdoo-master-win32/source\openerp\http.py", line 294, in checked_call
    return self.endpoint(*a, **kw)
  File "C:/GreenOdoo-master-win32/source\openerp\http.py", line 671, in __call__
    return self.method(*args, **kw)
  File "C:/GreenOdoo-master-win32/source\openerp\http.py", line 346, in response_wrap
    response = f(*args, **kw)
  File "C:\GreenOdoo-master-win32\source\addons\web\controllers\main.py", line 1050, in call_button
    action = self._call_kw(model, method, args, {})
  File "C:\GreenOdoo-master-win32\source\addons\web\controllers\main.py", line 1038, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
TypeError: get_product_provider() takes at least 6 arguments (5 given)

I have tried with different arguments but I don't know what else to do.

If you are using Functional Field then your method and No of parameters is correct. Example, def get_product_provider(self, cr, uid, ids, field_name, args, context=None): After changing the functional field code restart the server and update the module.

Prakash
on 8/12/14, 2:26 AM
9
Janeesh
On 8/12/14, 2:55 AM

Hi,

The method def get_product_provider(self, cr, uid, ids, context=None): is supposed to use for normal functions like button actions. Method def get_product_provider(self, cr, uid, ids, args, field_name, context=None): used for functional fields.

3
Roy Mathew
On 9/22/17, 3:14 AM

The method def get_product_provider(self, cr, uid, ids, context=None): is supposed to use for normal functions like button actions. Method def get_product_provider(self, cr, uid, ids, args, field_name, context=None): used for functional fields.

1

Hi,

Just change your defination as like below.

def get_product_provider(self, cr, uid, ids, field_name, args=none, context=None):
        res = {}
        for record in self.browse(cr, uid, ids, context=context):
            cr.execute('''select id from product_supplierinfo where product_tmpl_id in (select id from product_template) order by RANDOM() limit 1''')
            val = cr.fetchone()
            if val:
                res[record.id] = val[0]
            else:
                res[record.id] = False
            return res

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 8/11/14, 1:07 PM
Seen: 5093 times
Last updated: 9/22/17, 3:15 AM