Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Java ODOO Web API Client

By
Hassan Moulana
on 1/18/15, 9:07 AM 2,361 views

Dear Odoo Community Members,

I am trying to create a Sales Order from Java Client. I am sucessful by creating a draft quotation but i do not know how to add products into the quotation.

If anybody have a sample in another languages, please share. It will be helpful. 

Here is the code to create the quotation

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;


public class WSMain {

    static String url = "http://173.199.117.15:8069";
    static String db = "EverFresh";
    static String username ="admin";
    static String password = "a";
       
    public static void main(String[] args) throws Exception {

        final XmlRpcClient authClient = new XmlRpcClient();
        final XmlRpcClientConfigImpl authStartConfig = new XmlRpcClientConfigImpl();
        authStartConfig.setServerURL(
                new URL(String.format("%s/xmlrpc/2/common", url)));
        
        List configList = new ArrayList();
        Map paramMap = new HashMap();
        
        configList.add(db);
        configList.add(username);
        configList.add(password);
        configList.add(paramMap);
        
        int uid = (int)authClient.execute(
                authStartConfig, "authenticate", configList);

        final XmlRpcClient objClient = new XmlRpcClient();
        final XmlRpcClientConfigImpl objStartConfig = new XmlRpcClientConfigImpl();
        objStartConfig.setServerURL(
                new URL(String.format("%s/xmlrpc/2/object", url)));
        objClient.setConfig(objStartConfig);
        
        
        List paramList = new ArrayList();
                
        configList.clear();
        paramMap.clear();
        paramList.clear();
        
        configList.add(db);
        configList.add(uid);
        configList.add(password);
        configList.add("sale.order");
        configList.add("create");
                
        paramMap.put("partner_id", 1);
        
        paramList.add(paramMap);
        configList.add(paramList);

        int cid = (int)objClient.execute("execute_kw", configList);
        
        System.out.println("Your Sales Order is : " + cid);
        
        
    }

}

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/18/15, 9:07 AM
Seen: 2361 times
Last updated: 3/16/15, 8:10 AM