简体   繁体   English

Odoo API写入方法

[英]Odoo API write method

I've read other topics and also the full documentation. 我已经阅读了其他主题以及完整的文档。

I'm trying to write to a record. 我正在尝试写记录。 API returns "True", but there is no effect to the field. API返回“ True”,但对该字段无效。

write_to_db = models.execute_kw(db, uid, password,
    'mail.mass_mailing.contact', 'write', [ [the_contact[0]["id"]], { 'tag_ids': the_contact[0]["tag_ids"]}])

the_contact[0]["id"] is the id of the contact whose tags I want to change (add a new tag). the_contact [0] [“ id”]是要更改其标签(添加新标签)的联系人的ID。 the_contact[0]["tag_ids"] contains [1,2] ==> the new list of tags the_contact [0] [“ tag_ids”]包含[1,2] ==>新的标签列表

I'm aware that for one2many and many2many fields I need special syntax: https://www.odoo.com/documentation/10.0/reference/orm.html From (0, _, values) ... to (6, _, ids) But some of those syntax don't even has a place for new values!!! 我知道对于one2many和many2many字段,我需要特殊的语法: https ://www.odoo.com/documentation/10.0/reference/orm.html从(0,_,values)...到(6,_ ,ids),但是其中某些语法甚至都没有放置新值的地方!!! Just options 0 and 1... for the others one have just place to id??? 只是选项0和1 ...,其他选项仅是ID的地方??? But id is already in the command... 但是id已经在命令中了...

Tried many combinations but none worked. 尝试了多种组合,但均无效果。

(Bottom line: I'm a beginner in both Odoo and Python) (最重要的是:我是Odoo和Python的初学者)

Got the answer. 得到了答案。 The problem was not the syntax. 问题不在于语法。 "tag_ids" in fact are related to res.partner, not to mail.mass_mailing.tag 实际上,“ tag_ids”与res.partner有关,而不与mail.mass_mailing.tag有关

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM