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

Hi everybody.

Sorry to bother you but i'm newbie on using Open ERP webservices functionnalities. So I decided to use the OpenERP Java API in order to communicate with the Open Erp XML-RPC webservices.

At the moment, i manage to get the information about a sale order but i couldn't get data about the partner who order it.

Here is my code sample :

@WebMethod()
public Integer deployDocumentAPI(String nameFile) throws MalformedURLException {
    Session openERPSession = new Session("192.168.0.18", 8069, "hiveSharing", "webservice", "root");
    try {
        // startSession logs into the server and keeps the userid of the logged in user
        openERPSession.startSession();
        ObjectAdapter orderAd = openERPSession.getObjectAdapter("sale.order");
        FilterCollection filters = new FilterCollection();
        filters.add("name","=","SO001");
        RowCollection orders = orderAd.searchAndReadObject(filters, new String[]{"name","state","partner_id"});

        for (Row row : orders){
            System.out.println("Row ID: " + row.getID());
            System.out.println("Name:" + row.get("name"));
            System.out.println("Etat:" + row.get("state"));

            //everything is ok up to here

            //Adapter partner
            ObjectAdapter partnerAd = openERPSession.getObjectAdapter("res.partner");

            //row.get("partner_id") gives me an object that i can't manage to use

            RowCollection partners = partnerAd.readObject((Object[]) row.get("partner_id"), new String[]{"name"});

            for (Row rowP : partners){
                System.out.println("Partner:" + rowP.get("name"));
            }

        }
        return 1;

    } catch (Exception e) {
        System.out.println("Error while reading data from server:\n\n" + e.getMessage());
        return 0;
    }
}

According to the error I get, the readObject method is waiting for a collection of ids but how can i get the ids if I'am unable to read the object .....

It makes me crazy.

If someone is familiar to this APi, please help me ^^

PS : I'm french so sorry for my english ;-)

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

Try this way:

Object partnerID[] = (Object[]) row.get("partner_id"); System.out.println(partnerID[0]);

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

is this API still being used?

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 10 18
2984
0
thg 4 18
4134
java api Đã xử lý
1
thg 3 15
6201
0
thg 3 15
4226
0
thg 6 21
2383