Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
5322 Weergaven

Hi There,

we are newbies and need to access the database via API, to get data for our own scripts. I can read out all the partners with their attributs from res.partner but when I read products I only get the name. All the other attributes are empty. Of course they are not empty in Odoo himself. And the names of the attributes do macht these which you can see in the list, when you are in dev mode. I don´t know how to get access to the other Fields in product.product or product.template

So this is how I do it in PHP.

$user_id=connect();
print "<br>Login Status: ".$user_id;
print "<hr>";
$client = new xmlrpc_client($server_url.'object');
$keys = array (
            new xmlrpcval(
                    array(new xmlrpcval('name' , "string"),
                                new xmlrpcval('!=',"string"),
                                new xmlrpcval("","string")
                                ),"array"             
                    ),
            );
//////////////////////////////////////////////////////////
//$table = 'res.partner'; WORKS
//$field_list = array("name|string","email|string","street|string","city|string", "zip|string","sale_order_count|integer", "contact_address|string","property_stock_customer|string","property_product_pricelist|string","parent_name|string"); WORKS

$table = 'product.template'; //OR 'product.product'
$field_list = array("price|float","name|string","color|integer","qty_available|float","sale_ok|boolean","type|selection"); //////////////////////////////////////////////////////////

for($g = 0; $g < count($field_list); $g++){
if(stristr($field_list[$g],'|')){$fieldparts=explode('|',$field_list[$g]);$field_list[$g]=$fieldparts[0];$fieldtype=$fieldparts[1];}else{$fieldtype='string';}
    array_push($fieldobjects, new xmlrpcval($field_list[$g], $fieldtype));
}

$result=search($client,$table,'id',$keys,$fieldobjects);

for($i = 0; $i < count($result); $i++){
print "#".$i."<br>";
            $result[$i]->me['struct'];
            for($g = 0; $g < count($field_list); $g++){
                print $field_list[$g].": <span style='color:red'>".@$result[$i]->me['struct'][$field_list[$g]]->me['string']."</span><br>";
            }
            print "<hr>";

    }

What am I doing wrong, why I can´t get the other fields?

Thanks a lot, Martin

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
sep. 22
2710
1
sep. 20
6833
1
mrt. 15
10255
1
apr. 24
1080
0
jan. 23
5402