Salut à tous.
Je suis étudiant et dans le cadre de mon stage, je travaille sur le module CRM de odoo. L'objectif est de donner la possibilité aux clients de consulter les réclamations qu'ils ont eu à envoyer et ainsi suivre l'évolution du traitement de ces derniers [...]
J'utilise:
-le web Service XML-RPC pour me connecter à odoo (et son SGBD postgreSQL) -Merci à Thierry Godin pour son tuto-
-php comme langage programmation
Le problème se pose quand j'essaye de récupérer l'id du contact (address_id) auquel lié l'utilisateur dans la table res.users: l'id a bien une valeur, mais le résultat de la requête est vide
J'aimerais préciser que je suis un peu novice en matière de XML-RPC-PHP; j'ai un réel besoin d'aide, et je reste optimiste.
Merci d'avance.
Mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
public function getPid($uid, $password)
        {
            $pid;
            $con_user = new UserConnection();
            $client = new xmlrpc_client($con_user->getServerUrl() ."/xmlrpc/object"); 
            $userInfos;

            //Création du filtre de la requête
            $domain_filter = array ( 
            new xmlrpcval(
                array(new xmlrpcval("id" , "string"), 
                      new xmlrpcval("=","string"), 
                      new xmlrpcval($uid,"int"),
                      ),"array"             
                ),
            );

            //On exécute la methode search
            $msg = new xmlrpcmsg('execute'); 
            $msg->addParam(new xmlrpcval($con_user->getDbName(), "string")); 
            $msg->addParam(new xmlrpcval($uid, "int")); 
            $msg->addParam(new xmlrpcval($password, "string")); 
            $msg->addParam(new xmlrpcval("res.users", "string")); 
            $msg->addParam(new xmlrpcval("search", "string")); 
            $msg->addParam(new xmlrpcval($domain_filter, "array")); 
            $response = $client->send($msg);

            $rep = $response->value();        
            $result = empty($rep)? null : $rep;

            if ($rep != null) {
                $ids = $result->scalarval();

                //Création de la liste des ids récupérés
                $id_list = array();
            
                for($i = 0; $i < count($ids); $i++){
                    $id_list[]= new xmlrpcval($ids[$i]->me['int'], 'int');
                }

                //Création de la liste des champs à afficher
                $field_list = array(                  
                    new xmlrpcval("address_id", "string"),                         
                );

                //On execute la méthode read
                $msg = new xmlrpcmsg('execute');
                $msg->addParam(new xmlrpcval($con_user->getDbName(), "string"));
                $msg->addParam(new xmlrpcval($uid, "int"));
                $msg->addParam(new xmlrpcval($password, "string"));
                $msg->addParam(new xmlrpcval("res.users", "string"));
                $msg->addParam(new xmlrpcval("read", "string")); 
                $msg->addParam(new xmlrpcval($id_list, "array")); 
                $msg->addParam(new xmlrpcval($field_list, "array")); 

                $resp = $client->send($msg);

                if ($resp->faultCode()){
                    echo $resp->faultString();
                }

                $result = $resp->value()->scalarval();
                
                for($i = 0; $i < count($result); $i++){
               
                    $address_id = empty($result[$i]->me['struct']['address_id']->me['string'])? null :  $result[$i]->me['struct']['address_id']->me['string'];
                    $pid = $address_id;
                    echo '<h1>address_id: '. utf8_encode($address_id).'</h1>';
                    
                }
            }else
                $pid = -1;

             return $pid;
        }