0
我有2個模型:product.template
和product.brand
。 我想顯示來自product.template及其品牌的詳細數據,我可以從product.brand的模型中獲取品牌。在model.brand中,product.template中包含與id有關的product_id。這是我目前的代碼。此代碼僅顯示來自product.template的數據。如何使用ripcord在xmlrpc中加入模型?
<?php
$products = $ripcord->execute_kw('myDB', 1, 'myPassword',
'product.template', 'search_read',
array(
array(
array('name', 'ilike', 'pixma'),
array('type', 'ilike', 'product'),
['fields'=>array('name', 'description'), 'limit'=>5]
)));
?>
如何加入product.template模型與product.brand,以便我可以獲取數據的產品品牌。謝謝。
我明白了。 但是讓我們在'product.template'中包含字段:'id','name','type','brand'和'description'。並且在'product.brand'中包含字段:'id','brand_name','category_brand'和'price'。 'product.template'中的'brand'與'product.brand'中的'id'相關。我想要顯示的是'product.template'的'name'和'description','product.brand'的'category_brand'和'price'。 如果我只是把'品牌'領域像你說的,它只是顯示ID的品牌。我怎樣才能顯示'category_brand'和'price'? 謝謝:) – adn
據我所知,你必須提出多個請求。因此,您只需從product.brand中提取id,並針對該字段對該模型發出另一個「search_read」請求。可以編寫自己的幫助器方法來使用點符號並自動拉取關係,但Odoo的api不直接提供這些功能。 – holdenrehg
okey謝謝你的信息 – adn