Reputation: 111
I have a method which accepts an OValue:
getResults(OValues values)
Inside the method are the ff.
ORecordValues value = new ORecordValues();
value.put("order_partner_id", orderline.getPartner(values));
value.put("product_id", orderline.getProduct(values));
value.put("product_uom_qty",values.getInt("product_uom_qty"));
value.put("price_unit", values.getInt("product_uom_qty"));
value.put("discount",values.getInt("product_uom_qty"));
orderline.getServerDataHelper().createOnServer(value);
Is it possible to insert directly to Odoo's server without saving it to android's database? or any alternative ways to successfully insert data to Odoo server?
In ServerDataHelper java class:
public int createOnServer(ORecordValues data) {
OdooResult result = mOdoo.createRecord(mModel.getModelName(), data);
return result.getInt("result");
}
Upvotes: 0
Views: 122
Reputation: 26738
You need to pass server record id when creating records on the server.
Pass local row id(stored in _id
column) to the selectServerId method to get the server id (stored in id
column):
Check the following example:
ResPartner resPartner = new ResPartner(getApplicationContext(), null);
ProductProduct productProduct = new ProductProduct(getApplicationContext(), null);
...
ORecordValues value = new ORecordValues();
int partner_id = resPartner.selectServerId(values.getInt("partner_id"));
int product_id = productProduct.selectServerId(values.getInt("product_id"));
value.put("order_partner_id", partner_id);
value.put("product_id", product_id);
value.put("product_uom_qty",values.getInt("product_uom_qty"));
value.put("price_unit", values.getInt("product_uom_qty"));
value.put("discount",values.getInt("product_uom_qty"));
orderline.getServerDataHelper().createOnServer(value);
Upvotes: 0