如何使用撕裂绳在 xmlrpc 中加入模型?



我有 2 个模型:product.templateproduct.brand。 我想显示来自 product.template 及其品牌的详细数据,我可以从 product.brand 的模型中获得该品牌。在模型中 product.brand 包含与 product.template 中的 id 相关的product_id。这是我当前的代码。此代码仅显示来自产品模板的数据。

<?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]
))); 
?>

如何将产品模板模型与产品品牌联接,以便获取数据的产品品牌。谢谢。

您需要在fields中包含对品牌的引用。

<?php
$db = 'myDB';
$uid = 1;
$password = 'myPassword';
# You will need to include a reference to the Many2one field
# that exists on your product.template record. I'm assuming it's
# called something like "brand" or "brand_id"
$fields = array('name', 'description', 'brand');

$products = $ripcord->execute_kw($db, $uid, $password,
'product.template', 'search_read', array(array(
array('name', 'ilike', 'pixma'),
array('type', 'ilike', 'product'),
['fields'=> $fields, 'limit'=>5]))); 

最新更新