Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
7867 Widoki

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.

Awatar
Odrzuć
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.


Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
sie 16
5070
1
mar 17
4662
0
lis 15
3391
3
lip 25
2747
1
paź 24
1960