如何在 JAVA ODOO XMLRPC 中使用 many2one、many2many 数据创建记录
How To Create Record with many2one, many2many data in JAVA ODOO XMLRPC
这是我使用 Mpa 数据创建记录的函数
此函数将模型名称和数据作为输入来创建记录。
我的数据: {""categ_id":[1,"全部"],"website_meta_keywords":false, “available_in_pos”:真}
我的错误: 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;
}
Odoo 引发该错误是因为 categ_id
的值,Many2one 字段的值应该是现有的记录 ID(整数类型,也可以作为字符串传递)。
使用特殊的 commands 格式来操作存储 in/associated 的记录集,其中包含 x2many 字段。
示例(order_line
字段值):
Arrays.asList(Arrays.asList(0, 0, new HashMap() {{ put("product_id", product_id); ...}} ))
这是我使用 Mpa 数据创建记录的函数 此函数将模型名称和数据作为输入来创建记录。
我的数据: {""categ_id":[1,"全部"],"website_meta_keywords":false, “available_in_pos”:真}
我的错误: 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;
}
Odoo 引发该错误是因为 categ_id
的值,Many2one 字段的值应该是现有的记录 ID(整数类型,也可以作为字符串传递)。
使用特殊的 commands 格式来操作存储 in/associated 的记录集,其中包含 x2many 字段。
示例(order_line
字段值):
Arrays.asList(Arrays.asList(0, 0, new HashMap() {{ put("product_id", product_id); ...}} ))