英文:
How To Create Record with many2one, many2many data in JAVA ODOO XMLRPC
问题
**这是用于创建带有Mpa数据记录的函数**
此函数以*模型名称*和*数据*作为输入,以创建记录。
**我的数据:** *{"categ_id":[1,"All"],"website_meta_keywords":false,"available_in_pos":true}*
**我的错误:** *psycopg2.errors.InvalidTextRepresentation:错误:无效的输入语法为整数:“All”
第1行:...w() at time zone 'UTC'),true,true,0.0,ARRAY[1,'All'],'A...*
public Integer createRecord(String modelName, Map data) {
Integer recordId = -1;
try {
client.setConfig(objectConfig);
recordId = (Integer) client.execute("execute_kw", asList(
this.database, this.uid, this.password,
modelName, "create",
asList(
data
)
));
} catch (Exception e) {
LOGGER.error("[OdooXmlRpc.createRecord] 在" + modelName + "中创建记录时出现异常。详情:" + e.getMessage());
}
return recordId;
}
英文:
Here is my function for creating record with Mpa Data
This function take as input the model name and the data to create record.
My data: {"categ_id":[1,"All"],"website_meta_keywords":false,"available_in_pos":true}
My error: psycopg2.errors.InvalidTextRepresentation: ERREUR: syntaxe en entrée invalide pour l'entier : « All »
LINE 1: ...w() at time zone 'UTC'), true, true, 0.0, ARRAY[1,'All'], 'A...
public Integer createRecord (String modelName, Map data) {
Integer recordId = -1;
try {
client.setConfig(objectConfig);
recordId = (Integer) client.execute("execute_kw", asList(
this.database, this.uid, this.password,
modelName, "create",
asList(
data
)
));
} catch (Exception e) {
LOGGER.error("[OdooXmlRpc.createRecord] Exception when creating record in " + modelName + ". Details: " + e.getMessage());
}
return recordId;
}
答案1
得分: 0
Odoo引发了这个错误是因为categ_id
的值,Many2one
字段的值应该是一个现有记录的ID(整数类型,也可以作为字符串传递)。
使用特殊的命令格式来操作存储在/与x2many字段相关联的记录集。
示例(order_line
字段值):
Arrays.asList(Arrays.asList(0, 0, new HashMap() {{ put("product_id", product_id); ...}} ))
英文:
Odoo raised that error because of the value of categ_id
, the value of a Many2one field should be an existing record ID (of type integer, which can also be passed as a string).
Use a special commands format to manipulate the set of records stored in/associated with the x2many fields.
Example (order_line
field value):
Arrays.asList(Arrays.asList(0, 0, new HashMap() {{ put("product_id", product_id); ...}} ))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论