Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
7852 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
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.


Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 8 16
5068
1
thg 3 17
4654
0
thg 11 15
3386
3
thg 7 25
2704
1
thg 10 24
1937