我想要创造产品,我想要展示'categ_id‘如何才能完成'categ_id’。使用XML的字段many2one
发布于 2022-04-13 09:42:21
在以下示例中,我们从数据库中检索可销售类别的记录id,以创建新产品:
import xmlrpc.client
url =
db =
username =
password =
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
uid = common.authenticate(db, username, password, {})
models.execute_kw(db, uid, password, 'product.template', 'create',
[{'name': 'Test Product', 'categ_id': 1}])更新:
对于One2many和Many2many字段,Odoo使用一个特殊的命令来操作它们实现的关系,这种关系可以从XMLRPC中使用:
通过RPC,不可能使用函数,也不可能使用命令常量名称。它需要编写文字3元素元组,其中第一个元素是命令的整数标识符。
示例:(使用供应商价格表创建产品模板)
models.execute_kw(db, uid, password, 'product.template', 'create',
[{'name': 'Test Product',
'categ_id': 1,
'seller_ids': [(0, 0, {'name': 1,
'min_qty': 1000,
'price': 258.5,
'delay': 5
}
)]
}])对于其他操作,例如update__,您需要以下列格式指定记录id:(1, id, values)
https://stackoverflow.com/questions/71817333
复制相似问题