Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
5509 Ansichten

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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Sept. 22
2894
1
Sept. 20
7126
1
März 15
10417
1
Apr. 24
1380
0
Jan. 23
5640