Package fr.inouk

Examples of fr.inouk.OpenERPJSONRPCClient.modelSearchRead()


        OpenERPJSONRPCClient server = new OpenERPJSONRPCClient(SERVER_URL+":"+SERVER_PORT);
        JSONObject sessionInfo = server.sessionAuthenticate("openerp_jsonrpc_client", "admin", "admin", null, null);

        // res.users, 3 fields, all objects(no domain), no sort, no context
        // Note that we are supposed to have 40 + 1 users in database
        JSONObject objects = server.modelSearchRead("res.users", fieldNames, 0, 0, null, null, null);
        Integer userCount = (Integer) objects.get("length");
        Assert.assertTrue(userCount > 10, "naive search_read() failed. Are you sure you fill res_users with CallKW_fill_res_partner()");

    }
View Full Code Here


        OpenERPJSONRPCClient server = new OpenERPJSONRPCClient(SERVER_URL+":"+SERVER_PORT);
        JSONObject sessionInfo = server.sessionAuthenticate("openerp_jsonrpc_client", "admin", "admin", null, null);

        // Test sort parameters
        JSONObject sortedObjects = server.modelSearchRead("res.users", fieldNames, 0, 0, null, "id", null);
        Integer sortedObjectCount = (Integer) sortedObjects.get("length");
        Integer idOf5th = (Integer) ((JSONObject)((JSONArray)sortedObjects.get("records")).get(5)).get("id");
        Integer idOf6th = (Integer) ((JSONObject)((JSONArray)sortedObjects.get("records")).get(6)).get("id");
        Assert.assertTrue( idOf5th == idOf6th - 1, "Humm search_read() with sort failed.");
View Full Code Here

        Integer idOf5th = (Integer) ((JSONObject)((JSONArray)sortedObjects.get("records")).get(5)).get("id");
        Integer idOf6th = (Integer) ((JSONObject)((JSONArray)sortedObjects.get("records")).get(6)).get("id");
        Assert.assertTrue( idOf5th == idOf6th - 1, "Humm search_read() with sort failed.");

        // sort 'DESC'
        sortedObjects = server.modelSearchRead("res.users", fieldNames, 0, 0, null, "id desc", null);
        sortedObjectCount = (Integer) sortedObjects.get("length");
        idOf5th = (Integer) ((JSONObject)((JSONArray)sortedObjects.get("records")).get(5)).get("id");
        idOf6th = (Integer) ((JSONObject)((JSONArray)sortedObjects.get("records")).get(6)).get("id");
        Assert.assertTrue( idOf5th == idOf6th + 1, "Humm search_read() sort failed.");
        System.out.println(sortedObjectCount + "sortedObjects:");
View Full Code Here

        OpenERPJSONRPCClient server = new OpenERPJSONRPCClient(SERVER_URL+":"+SERVER_PORT);
        JSONObject sessionInfo = server.sessionAuthenticate("openerp_jsonrpc_client", "admin", "admin", null, null);

        // Test domain parameter
        JSONArray domain_expr = new JSONArray("[['id','>',5],['id','<',10]]");
        JSONObject filteredObjects = server.modelSearchRead("res.users", fieldNames, 0, 0, domain_expr, "id", null);
        Integer filteredObjectCount = (Integer) filteredObjects.get("length");
        Assert.assertTrue( filteredObjectCount == 4, "Humm search_read() with a domain failed !");
        System.out.println("We got " + filteredObjectCount + " filteredObjects:");
        System.out.println(filteredObjects);
View Full Code Here

         * To test offset and limit we search to overlapping pages and we check that the first id of the second page equals
         * the last id of the first page.
         */

        // First page: offset = 0 and limit = 2 (so response is printable)
        JSONObject paginatedObjects = server.modelSearchRead("res.users", fieldNames, 0, 2, null, "id", null);

        // We test limit
        Integer paginatedObjectCount = ((JSONArray)paginatedObjects.get("records")).length();
        System.out.println("We got "+paginatedObjectCount + " paginatedObjects:");
        System.out.println(paginatedObjects);
View Full Code Here

        Assert.assertEquals( paginatedObjectCount.intValue(), 2, "Humm search_read() with limit and offset failed on the limit).");

        int idOfLastObjectOfPage1 = ((Integer)((JSONObject)((JSONArray)paginatedObjects.get("records")).get(1)).get("id")).intValue();

        // Second page: offset = 1 and limit = 2
        JSONObject page2Objects = server.modelSearchRead("res.users", fieldNames, 1, 2, null, "id", null);
        int idOfFirstObjectOfPage2 = ((Integer)((JSONObject)((JSONArray)page2Objects.get("records")).get(0)).get("id")).intValue();

        // We test offset
        Assert.assertEquals( idOfLastObjectOfPage1, idOfFirstObjectOfPage2, "Humm search_read() with limit and offset failed (offset).");
View Full Code Here

        JSONObject sessionInfo = server.sessionAuthenticate("openerp_jsonrpc_client", "admin", "admin", null, null);

        // First we search for sale module id
        JSONArray domain = new JSONArray("[['name','=','sale']]");
        String[] fields = { "name", "state"};
        JSONObject jsonResult = server.modelSearchRead("ir.module.module", fields, 0, 0, domain, null, null);
        JSONObject moduleObject = (JSONObject) ((JSONArray) jsonResult.get("records")).get(0);
        Long saleModuleId = ((Integer)moduleObject.get("id")).longValue();
        System.out.println("Sale module (before install)= " + moduleObject);
        Assert.assertEquals("uninstalled", (String) moduleObject.get("state"), "Sale module is already installed");
View Full Code Here

        JSONArray args = new JSONArray("[[" + saleModuleId + "]]")// Notice that the argument we sent is an array !!
        Object objResult = server.modelCallKW("ir.module.module", "button_immediate_install", args, null, null);
        // Server returns us an ir.actions to open a menu. We can't process it.
        System.out.println("objResult = "+objResult);

        jsonResult = server.modelSearchRead("ir.module.module", fields, 0, 0, domain, null, null);
        moduleObject = (JSONObject) ((JSONArray) jsonResult.get("records")).get(0);
        System.out.println("Sale module (after install)= " + moduleObject);
        Assert.assertEquals("installed", (String) moduleObject.get("state"), "Sale module installation failed");
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.