在Odoo 12中更新路线

在Odoo 12中更新路线,odoo,Odoo,如何使用查询更新Odoo 12中的产品Route\u idroutes 选择的产品,我可以做的回答从这个链接。 谢谢 也许有了这些: models.execute_kw(db, uid, password, 'product.template', 'write', [[id], {'route_ids': [(1, a, b)]}]) 什么是a和b?我认为这是为了更新,对吗 我认为答案是这样的,但我不确定: models.execute_kw(db, uid, password, 'pr

如何使用查询更新Odoo 12中的产品
Route\u id
routes

选择的产品,我可以做的回答从这个链接。

谢谢 也许有了这些:

models.execute_kw(db, uid, password, 'product.template', 'write', [[id], {'route_ids': [(1, a, b)]}])  
什么是a和b?我认为这是为了更新,对吗

我认为答案是这样的,但我不确定:

models.execute_kw(db, uid, password, 'product.template', 'write', [[id], {'route_ids': [(1, 915, 17)]}])
1
表示更新,
915
表示产品id,
17
表示路线id

问题是我如何做一个产品列表来更新路线? 根据卓尔纳的回答,也许是

模型.execute_kw(db,uid,pw,'product.template', '写',[[17],{'route_id':[(6,0,[915916])]}]

是吗

好的,我要做:

import sys
import xmlrpclib
import ssl

url = "http://localhost:8069"
db = "*******"
username = "*******"
pw = "*******"

gcontext = ssl._create_unverified_context()

# Get the uid

    sock_common = xmlrpclib.ServerProxy(
        "http://localhost:8069/xmlrpc/common", context=gcontext)

    uid = sock_common.login(db, username, pw)
    models = xmlrpclib.ServerProxy("http://localhost:8069/xmlrpc/object", context=gcontext)
    
    models.execute_kw(
        db, uid, pw, "product.template", "write", [[916], {"route_ids": [(6, 0, [17])]}]
    )
不行,我的错在哪里


这些代码与odoo 12一起工作?

关于如何使用odoo中的许多字段的魔法三元组,已经有很多答案了。我对这个基本问题的建议是:查看
BaseModel.write()
的docstring,因为这个问题的答案已经存在很久了

但对于您的特殊问题:如果您想将产品路线设置为仅一条路线,只需使用“覆盖”三元组
(6,0,)
。如果您只想向所有当前设置的路由添加另一个路由,请使用“添加”三元组
(4,0)
(您可以在末尾保留0)

因此,如果Make2order路由是例如ID 3:

models.execute_kw(db,uid,pw,'product.template',
'write',[[template_id],{'route_id':[(6,0,[3])]}]

models.execute_kw(db,uid,pw,'product.template',
'write',[[template_id],{'route_id':[(4,3,)]}])

因此,我将列出一份编号为915和916的产品清单,对吗?models.execute_-kw(db,uid,pw,'product.template','write',[[template_-id],{'route_-id':[(6,0,[915916])}]),我如何将route_-id 17放入这些产品?谢谢,三人组将获得路由ID。产品id属于我编写template_id的地方。Odoo希望为method
write
提供两个方法参数,这将是一个要写入/更新的id列表和一个python字典,其中字段名作为键,还有一些值要写入。好的,谢谢,我已经使用批量编辑模块解决了问题,我知道最好按照您所说的CZoellner进行操作。谢谢。