Skip to Content
Menu
This question has been flagged
4 Replies
10147 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.

Avatar
Discard

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.

Best Answer

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.

Avatar
Discard
Best Answer

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.

Avatar
Discard
Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
1
Aug 23
12546
1
Aug 23
11049
1
Jul 23
7225
4
Apr 23
8676
2
Feb 23
17592