尝试通过 API 在销售订单行中添加服务产品时出现 "Record does not exist or has been deleted " 错误

Getting "Record does not exist or has been deleted " error when trying to add service product in sales order line via APIs

我正在按照文档使用 Odoos API:https://www.odoo.com/documentation/13.0/webservices/odoo.html

尝试将服务产品添加到销售订单行时,出现错误:

xmlrpc.client.Fault: <Fault 2: "('Record does not exist or has been deleted.\n(Record: product.product(14589,), User: 2)', None)">

只有在我尝试添加新创建的服务产品时才会出现这种情况。但是当添加我们迁移到 Odoo 13 之前已经存在的旧服务产品时,它工作正常。

我添加服务产品订单行如下:

order_line_id = models.execute_kw(db, uid, password, 'sale.order.line', 'create', [{
'order_id':sales_order_id
,'product_id':odoo_product_id
,'name': product_sku
,'price_unit':product_price
,'product_uom_qty':product_quantity
,'state':'sale'
,'qty_delivered_method': 'manual'
,'customer_lead': 0.0
,'invoice_status':'no'
,'product_type': 'service'
}])

有人知道是什么原因造成的吗?

确保您使用的是 product.product 而不是 product.template,这是一个常见的错误。