通过 Odoo 添加产品到新的销售报价 API (Java)

Adding products to a new sales quote through the Odoo API (Java)

我正在通过 Odoo API 以编程方式创建新的销售报价,如下所示:

final Object orderLineItem = asList((Object[]) models.execute("execute_kw", asList(
    db, uid, password,
    "sale.order.line", "search",
    asList(asList()),
    new HashMap() {{
      put("limit", 10);
    }})
  )).get(0);

final Integer id = (Integer) models.execute("execute_kw", asList(
    db, uid, password,
    "sale.order", "create",
    asList(new HashMap() {{
      put("currency_id", resCurrency);
      put("date_order", dateTime);
      put("partner_id", resPartnerId);
      put("picking_policy", "");
      put("pricelist_id", productPricelistId);
      put("name", name);
      put("warehouse_id", stockWarehouseId);
      put("partner_invoice_id", resPartnerId);
      put("partner_shipping_id", resPartnerId);
      put("access_token", "");
      put("order_line", asList(
        asList(1, false, new HashMap<String, Object>() {{
          put("product_id", orderLineItem);
        }})));
    }})
  ));

但是,我无法在报价单的 order_line 部分列出产品。 Order_line 具有一对多关系,但我不确定这是与可以销售给客户的产品的关系,还是完全不同的关系。

我知道 sale.order.line 资源包含我所有的 'order_lines' 或产品,但我不确定如何将这些产品添加到新的销售报价中。

如能提供 Java 或 python 同等帮助,我们将不胜感激。

通过将 orderLineItem 设为 product.prodcut

的资源解决了这个问题
import java.util.Arrays;
import java.util.HashMap;

import parapremium.beans.Product;

public class CreateSaleOrder extends Service {

    private int userid;

    public CreateSaleOrder() throws Exception {
        super();
        userid=(new Authenticate()).getUserId();
    }

    public int createOrder() throws Exception
    {
        final int inv=(int) client.execute("execute_kw", Arrays.asList(
                  database, userid, password,
                  "sale.order", "create",
                  Arrays.asList(new HashMap<String, Object>() {{ 
                         put("partner_id", 1);
                         put("currency_id", 1);
                         //  put("date_order", dateTime);
                         put("picking_policy", "");
                         put("pricelist_id", 2);
                         //put("name", "Order");
                         // put("warehouse_id", 15);
                         put("access_token", "");
                    }})
                ));

        return inv;
    }

    public int createOrderLine(final int inv, int id, final double new_qty) throws Exception
    { 
        final int id_product=id;

         client.execute("execute_kw", Arrays.asList(
                  database, userid, password,
                  "sale.order.line", "create", Arrays.asList(new HashMap<String, Object>() {{ 
                      put("order_id", inv); 
                      //put("theoretical_qty", th_qty); 
                      put("product_id", id_product); 
                      put("product_qty", new_qty);
                      //  put("product_uom", 1);
                      put("discount", 10);
                 }})    ));       

          return 1;
    }


    public static void main(String arg[]) throws Exception
    {
        CreateSaleOrder createOrderLine = new CreateSaleOrder();
        int i = createOrderLine.createOrder();
        System.out.print( i );
        System.out.print( createOrderLine.createOrderLine(i,1001, 4) );
    }
}