Odoo How To Create Many2one Record From Android Studio Using Axmlrpc Library?
Solution 1:
I am answering my own question. The answer for this problem is very simple which I found out exploring, debugging and trying things out with XMLRPC library. This is how I solved it. The field I was trying to update only accepts the data that is already preset in odoo. For example: I had to first search for the available preset data for that field by using search_read functionality. Like..
OdooConnect oc = OdooConnect.connect(SERVER_URL, PORT_NO, DB_NAME, USER_ID, PASSWORD);
List<HashMap<String, Object>> data = oc.search_read("fleet.vehicle", newObject[]{
newObject[]{condition}}, "id");
What I am doing here is searching for all the preset data related to the field I want to create and get the id of the string that matches with the one I want to update with certain conditions. here condition is
newObject[]{newObject[]{newObject[]{"name", "=", "Audi A3"}}}
so when it matches with that condition, it returns the id of the object I need to pass to the many2one field. In the above code "id" is for asking for an id of the string that matched the condition. Now we will pass the id while creating a new record to many2one field. Pass the id to below create method.
finalIntegeridC= oc.create("web.service", newHashMap() {{
put("name", "Final Test");
put("value", 29); //
put("partner_id", id); //many2One field. here we are using pre defined value i,e setting a value of other relation model to partner_id
}});
Hope it helps someone who is looking for an answer. :)
Solution 2:
From the traceback sycopg2.DataError: invalid input syntax for integer: "Audi A3"
is saying you passing a non-integer value. Just replace Audi A3
with id. Then try again.
Hope it will help you.
Post a Comment for "Odoo How To Create Many2one Record From Android Studio Using Axmlrpc Library?"