новичок в Odoo, я пытаюсь создать веб-сервис в Java, загружая данные в Odoo, в частности, в модели product.template и technical.sheet, пользовательскую модель, которую я создал. Для одного продукта может быть 0 или много технических листов, а для одного технического листа - один продукт. В техническом листе модели я создал поле x_product_id, тип - many2one и отношение объекта - product.tamplate. В product.template я создаю то же поле x_product_id, но тип one2many, отношение объекта - technical.sheet и отношение поля x_product_id (technical.sheet). Мне удалось загрузить продукты и технические таблицы, но когда я пытаюсь установить реляционные поля, я получаю ошибки. У кого-нибудь есть пример или идея, как устанавливать поля типа one2many, many2one и many2many, используя внешний API Odoo? Спасибо! Это кусок кода:
для (Статья статьи: Articles.values ()) {
if(article.getTechSheets().size()>0){
technicalSheetsMap.put(article.getMfsIdentifier(), article.getTechSheets());
}
ArrayList<Integer> techSheetsIds = new ArrayList<>();
for(TechnicalSheet sh: article.getTechSheets()){
techSheetsIds.add(Integer.valueOf(sh.getId()));
}
ArrayList<Integer> arrids = new ArrayList<Integer>();
arrids.add(Integer.valueOf(article.getMfsIdentifier()));
/* Load of the article into model product.tamplate of the odoo database */
final Integer id = (Integer)models.execute("execute_kw", Arrays.asList(
db, uid, password,"product.template", "create",
Arrays.asList(new HashMap() {{
put("is_published", true);
put("active", true);
put("x_standartization_level", article.getStandartizationLevel());
put("id", Integer.valueOf(article.getMfsIdentifier()));
put("default_code", article.getCode());
put("name", article.getLabelEn());
put("x_msf_identifier", article.getMfsIdentifier());
put("display_name", article.getLabelEn());
put("x_label_en", article.getLabelEn());
put("x_oca", article.isOca());
put("x_ocb", article.isOcb());
put("x_ocba", article.isOcba());
put("x_ocg", article.isOcg());
put("x_ocp", article.isOcp());
put("x_cold_chain_group", article.getTermosensitive());
put("x_justification_id", article.getJustificationId());
put("x_transport_un_code_id", article.getTransportUnCodeId());
put("x_picture_content", article.getPictureNb());
put("x_picture_label", article.getPictureLabel());
put("x_controlled_substance", article.getControlledSubstance());
put("x_medical_device_class", article.getMedicalDeviceClass());
put("x_code", article.getCode());
put("x_type", article.getType());
put("x_family_id", article.getFamilyId());
put("x_group_id", article.getGroupId());
put("x_who_id", article.getWhoIds());
put("x_product_id", Integer.valueOf(article.getMfsIdentifier()));
}})
));
for(TechnicalSheet sheet: article.getTechSheets()){
final Integer idsh = (Integer)models.execute("execute_kw", Arrays.asList(
db, uid, password,
"x_product.technical_sheet",
"create",
Arrays.asList(new HashMap(){{
put("id", sheet.getId());
put("x_name", sheet.getLabelEn());
put("x_description", sheet.getDefinition());
put("display_name", sheet.getLabelEn());
put("x_product_id", Integer.valueOf(article.getMfsIdentifier()));
put("x_norms", sheet.getNorms());
put("x_precat", sheet.getPrecat());
}})
));
}
}