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

I am getting this error DataError: invalid input syntax for integer: "{'random_seller_info_id': 6}"

By
Emmanuel Roldan
on 8/7/14, 4:29 PM 3,539 views

I am getting this error can anyone help?

Here is the Traceback :

    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 4430, in _store_set_values
    '"'+f+'"='+self._columns[f]._symbol_set[0] + ' where id = %s', (self._columns[f]._symbol_set[1](value), id))
  File "C:/GreenOdoo-master-win32/source\openerp\sql_db.py", line 155, in wrapper
    return f(self, *args, **kwargs)
  File "C:/GreenOdoo-master-win32/source\openerp\sql_db.py", line 230, in execute
    res = self._obj.execute(query, params)
DataError: invalid input syntax for integer: "{'random_seller_info_id': 6}"
LINE 1: ...oans_e3loan_services" set "random_seller_info_id"='{''random...
                                                                                                    ^

and my code:

class itaconloans_e3loan_services(osv.osv):
    """ Itacon loans application 'E3 Loan Application services' """
    _name = 'itaconloans.e3loan.services'
    _description = 'Loans services'

    def get_product_provider(self, cr, uid, ids, args, field_names, context=None):
        res = {}
        for record in self.browse(cr, uid, ids, context=context):
            cr.execute('''select name 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] = {'random_seller_info_id': val[0]}
                res[record.id]['random_seller_info_id'] = val[0]

        return res


    _columns = {
        'ServicesID': fields.char('Services ID', size=15),
        'product_id': fields.many2one('product.product', 'name', 'Service Name'),

        'AppNum': fields.many2one('itaconloans.e3loan', 'Application Number', select=True),

        'provider': fields.many2one('res.partner', 'Provider Name', select=True),

        'DateReq': fields.date('Date Requested'),
        'DateComp': fields.date('Date Completed'),
        'DateToComp': fields.date('Date To Complete'),
        'comments': fields.text('Comments', translate=True),

        'random_seller_info_id': fields.function(get_product_provider, type='many2one', relation="product.supplierinfo", string="Random Supplier", store=True),
    }

itaconloans_e3loan_services()

Thank you prakash, it got rid of that error. But now I am getting: 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)

Emmanuel Roldan
on 8/8/14, 1:40 PM
1

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 8/8/14, 5:28 AM

In your code random_seller_info_id function field type 'many2one' but in the code sql select statement return the name of the product_supplierinfo change into ID.

Example,

    def get_product_provider(self, cr, uid, ids, args, field_names, 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

EDIT:-

https://doc.odoo.com/6.0/developer/2_5_Objects_Fields_Methods/field_type/

The id of the function is retrieved using a SQL query. Note that if the query returns no result, the value of sql res will be None. We force the False value in this case value because XML:RPC (communication between the server and the client) doesn't allow to transmit this value.

0
Emmanuel Roldan
On 8/8/14, 3:00 PM

Thank you prakash, it got rid of that error. But now I am getting: 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)

Hi, see the functional document:- https://doc.odoo.com/6.0/developer/2_5_Objects_Fields_Methods/field_type/ i updated my code based on the examples given in the document.

Prakash
on 8/11/14, 1:38 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

2 follower(s)

Stats

Asked: 8/7/14, 4:29 PM
Seen: 3539 times
Last updated: 3/16/15, 8:10 AM