gpt4 book ai didi

android - 插入一对多和多对一字段

转载 作者:行者123 更新时间:2023-11-29 16:47:36 26 4
gpt4 key购买 nike

我正在使用 android odoo-mobile 框架,这就是我在 createRecord() 的帮助下在线插入记录的方式,现在我想在 odoo 数据库的 manyTomany 和 oneTomany 字段中插入记录。我不知道如何在线插入它。请帮助我。谢谢!

这就是我在线插入/创建新记录的方式。

protected OdooResult doInBackground(Void... voids)
{
ORecordValues values = new ORecordValues();
values.put("partner_id", Integer.parseInt(resPartnerArrayList.get(idc).get_id()));
String UTCDate = toUTCTime(binding.qOrderDate.getText().toString())
values.put("date_order", UTCDate);
if(!expDate.isEmpty())
{
values.put("validity_date",binding.qExpirationDate.getText().toString());
}
if(!paymentTerms.isEmpty())
{
values.put("payment_term_id", Integer.parseInt
(paymentTermArrayList.get(idP).get_id()));
}
if(!binding.qUntaxedAmount.getText().toString().isEmpty())
{
values.put("amount_untaxed",binding.qUntaxedAmount.getText().toString());
}
if(!binding.qTotal.getText().toString().isEmpty())
{
values.put("amount_total", binding.qTotal.getText().toString());
}
if(!binding.qTaxes.getText().toString().isEmpty())
{
values.put("amount_tax", binding.qTaxes.getText().toString());
}
return odoo.createRecord("sale.order", values);
}

最佳答案

关系字段接受命令列表:

    [(cammond_valeu, value, value), ........] 

在 many2many 中插入 id 列表

   [(6, 0, [id1, id2, id3])] # this remove old record and replace them by this new ids
[(4,id,0), (4, id2, 0), ....] # this add the list of ids to m2m without removing the old record
[(0, 0, {'field_name': value, 'field_name2': value}), ...] # this create an new record from the dictionary and add it to old record

更多理解:

insert into many2many odoo

关于android - 插入一对多和多对一字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47414114/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com