openerp XML RPC search by many2one id


openerp XML RPC search by many2one id

我目前正在使用XMLRPC API将网站连接到openerp。这个想法是我们想从openerp获得最新的库存数量。目前我正在使用这个连接器库.这是我的 openerp api 中的示例数据

[0] => Array
        (
            [create_date] => 2016-01-26 03:02:29
            [qty] => 6
            [propagated_from_id] => 
            [package_id] => 
            [cost] => 1500000
            [inventory_value] => 9000000
            [lot_id] => 
            [reservation_id] => 
            [id] => 2
            [negative_dest_location_id] => 
            [create_uid] => Array
                (
                    [0] => 1
                    [1] => Administrator
                )
            [display_name] => 17326: 6.0Unit(s)
            [__last_update] => 2016-01-26 03:02:29
            [location_id] => Array
                (
                    [0] => 19
                    [1] => Warehouse 1/Stock
                )
            [company_id] => Array
                (
                    [0] => 1
                    [1] => PT. ONE WAY
                )
            [history_ids] => Array
                (
                    [0] => 2
                )
            [owner_id] => 
            [write_date] => 2016-01-26 03:02:29
            [write_uid] => Array
                (
                    [0] => 1
                    [1] => Administrator
                )
            [name] => 17326: 6.0Unit(s)
            [product_id] => Array
                (
                    [0] => 2756
                    [1] => [17326]  AEG Vacuum Cleaner Dust Extractor Wet & Dry AP 20
                )
            [packaging_type_id] => 
            [negative_move_id] => 
            [in_date] => 2016-01-26 03:02:29
        )

如何按product_id过滤该数据

[product_id] => Array
                (
                    [0] => 2756
                    [1] => [17326]  AEG Vacuum Cleaner Dust Extractor Wet & Dry AP 20
                )

这是我的代码

$rpc = new OpenERP();
$x = $rpc->login("supermin", "my_site", "my_pass", "http://111.222.33.44:8069/xmlrpc/");
$data = $rpc->searchread(
    array(
        array("model", "=", "product.product"),
        array("module", "=", "sale"),
        array("product_id", "=", "2756"),
    ),
    "stock.quant"
);  

任何示例都会有所帮助。谢谢

尝试使用这个:

//... your source
$data = $rpc->searchread(
    array(
        array('model', '=', 'product.product'),
        array('module', '=', 'sale'),
        array('product_id', '=', '2756'),
    ),
    'stock.quant',
    array(), // default
    0, // default
    10, // default
    'product_id DESC' // default value was 'id DESC'
);  

我没有使用连接器库,但是如果我们检查OpenERP类的searchread()方法,我们可以看到默认$order = "id DESC"

希望这对你有帮助。