Ad
Many2Many Field Insertion In Odoo Request Not Working In Android
I'm trying to create a meeting with attendees in Odoo, The attendees fields is many2many field. if I don't add it to the request, the meeting is created just fine without attendees. However , if I add the "partner_ids"
key that corresponds to the many2many field. The meeting does not appear. Here are samples of what I tried :
// Attempt 1 : add them as an integer array
List<Integer> partnerIds= new ArrayList<>();
partnerIds.add(15403);
partnerIds.add(7567);
partnerIds.add(7564);
// Attempt 2 : add them in a hashmap array;
List<HashMap<String,Integer>> hashMapList= new ArrayList<>();
HashMap<String,Integer> hashMap= new HashMap<>();
hashMap.put("id",15401);
HashMap<String,Integer> hashMap2= new HashMap<>();
hashMap2.put("id",15400);
HashMap<String,Integer> hashMap3= new HashMap<>();
hashMap3.put("id",15399);
hashMapList.add(hashMap);
hashMapList.add(hashMap2);
hashMapList.add(hashMap3);
attempt 3 : add them into a list of objects as mentioned here
List<Object> testObj= new ArrayList<>();
//Object obj = new Object();
testObj.add(0);
testObj.add(0);
testObj.add(hashMapList);
List<Object> manyToManyRecord = new ArrayList<>();
manyToManyRecord.add(testObj);
Log.d("manyToManyRecord", manyToManyRecord.toString());
OdooValues values = new OdooValues();
values.put("opportunity_id",25619);
values.put("partner_ids", manyToManyRecord);
values.put("name", "App Discussion Meet ");
values.put("start", "2019-03-27 10:00:00");
values.put("stop", "2019-03-27 20:00:00");
values.put("allday", false);
values.put("day", 0);
values.put("user_id", 1);
values.put("active", true);
values.put("recurrent_id", 0);
values.put("x_project_latitude", 0);
values.put("x_project_longitude", 0);
values.put("description", "Test Meeting Description");
client.create("calendar.event", values, new IOdooResponse() {
@Override
public void onResult(OdooResult result) {
int serverId = result.getInt("result");
Log.d("Meeting Id", String.valueOf(serverId));
}
});
So where is the mistake I am making ? Any help with the steps is appreciated!
Ad
Answer
This solution worked for me :
//The 15401,15400... are static ids that were inputted for testing
values.put("partner_ids", asList(asList(6, 0, asList(15401,15400,15399))));
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad