Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
7873 Переглядів

I am an android developer who is now working with OODO API. My aim is to read a specific amount of data present in the res.partner object in the OpenERP.

I used the below code to get all the data's present in the res.partner object.

  String[] arrayOfString4 = new String[4];

  arrayOfString4[0] = "name";

  arrayOfString4[1] = "date";

  arrayOfString4[2] = "state_id";

  arrayOfString4[3] = "ho_branch_id";

  arrayOfString4[4] = "client_id";

  tableId = (Object[]) client1.call("execute", DB_NAME, UID, PASSWORD, "res.partner", "search", new Object[0]); Object[]      

 tableitems = (Object[]) client1.call("execute", DB_NAME, UID, PASSWORD, "res.partner", "read", tableId, arrayOfString4);

This code retrieves more than 20,000 data's where I only need the first 50 data's. I checked this OODO API link for a solution.And from there I tried this.

tableId = (Object[]) client1.call("execute", DB_NAME, UID, PASSWORD, "res.partner", "search", new Object[0],new HashMap() {{ put("limit",50); }});

Object[] tableitems = (Object[]) client1.call("execute", DB_NAME, UID, PASSWORD, "res.partner", "read", tableId, arrayOfString4);

But I get an error java.lang.string cannot be converted into java.lang.integer Can anyone please help me how to limit the number of data's read??? I hope my question is clear enough..I am new at this. Thank you.

Аватар
Відмінити
Hi.

I'm sorry...I am new to the oodo forum....Could you tell me if you answered my question??
I cannot find the answer in the page where I posted my question.

Thank you.

 

On Tue, Feb 21, 2017 at 12:45 PM, Ermin Trevisan <trevi@twanda.com> wrote:

A new question How to limit reading data in XMLRPC android on Help has been posted. Click here to access the question :

See question

--
Ermin Trevisan


Sent by Odoo S.A. using Odoo.


Найкраща відповідь

which API are you using ??

 is it Odoo External Api ??.


In the Odoo External Api Documentation is explaining that ,  you can set the limit for the reading Records in Read and Search_read methods ,  and you can set the offset and the limit if need . refer the link

https://www.odoo.com/documentation/11.0/webservices/odoo.html

Аватар
Відмінити
Найкраща відповідь

use fields as this example :

def getConvert(self, partner_id):
    modelName = 'membership.membership.line'                       
    domain = [ ('partner_id','=',partner_id )]       
    fields =[
            'id',
             'partner_id',
             'name', ]
        user = self.execute(modelName, 'search_read',    [domain,    fields])
        try :
            userId = user[0]['id']
            logger.info("converted ParterId :" + str(partner_id)+ " == UserId ids : " + str(userId))
        except IndexError as e:
            logger.warn(str(e) + "can not converted - no UserId for Partner:" + str(partner_id))
            userId = False
        return  userId

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
серп. 16
5071
1
бер. 17
4662
0
лист. 15
3397
3
лип. 25
2754
1
жовт. 24
1962