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_product_provider() takes at most 5 arguments (7 given)

By
Emmanuel Roldan
on 8/11/14, 1:07 PM 3,740 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
1

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 8/12/14, 2:30 AM

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

5

Janeesh

--Janeesh--
1641
| 4 3 4
Cochin, India
--Janeesh--

Odoo Developer

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.

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

2 follower(s)

Stats

Asked: 8/11/14, 1:07 PM
Seen: 3740 times
Last updated: 3/16/15, 8:10 AM