繁体   English   中英

通过many2one id进行openerp XML RPC搜索

[英]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"

希望这对您有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM