title: Create Leads on OpenERP/Odoo from XML-RPC client
body: <p>I'm trying to create Lead into Odoo v8, from a <code>php</code> form.</p>
  
  <p>From this form I send the message via <code>POST</code> to an xml-rpc client, then this client sends it to Odoo and creates a Lead on it.</p>
  
  <p>I'm trying hard but with no success so far, this is my <code>form.php</code> code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Contact form&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h4&gt;Contact Form&lt;/h4&gt;
  &lt;form method="post" action="crmlead.php"&gt;
  &lt;label for="firstname"&gt;Firstname&lt;/label&gt;
      &lt;input type="text" name="name" value="" id="name" class="required text" title="Please, fill in your firstname" data-required="true"&gt;&lt;br /&gt;
      &lt;label for="partner_name"&gt;Partner Name&lt;/label&gt;
      &lt;input type="text" name="partner_name" value="" id="partner_name" class="required text" title="Please, fill in your company name" data-required="true"&gt;&lt;br /&gt;
      &lt;label for="event_date"&gt;Event Date&lt;/label&gt;
      &lt;input type="text" name="event_date" value="" id="event_date" class="required text" title="Please, fill in your job title" data-required="true"&gt;&lt;br /&gt;
      &lt;label for="email"&gt;Email&lt;/label&gt;
      &lt;input type="text" name="email" value="" id="email" class="required email text" title="Please, enter a valid email address" data-required="true"&gt;&lt;br /&gt;
      &lt;label for="phone"&gt;Phone&lt;/label&gt;
      &lt;input type="text" name="phone" value="" id="phone" class="required phone text" title="Please use international format (eg: +32...)" data-required="true"&gt;
  
      &lt;label for="guests"&gt;Guests&lt;/label&gt; 
      &lt;input type="text" name="guests" value="" id="guests" class="required text" title="Please, fill in your city" data-required="true"&gt;&lt;br /&gt;
      &lt;label for="budget"&gt;Budget&lt;/label&gt;
      &lt;td&gt;&lt;input type="text" name="budget" value="" id="budget" class="required text" title="Please, fill in your zipcode" data-required="true"&gt;&lt;br /&gt;
  &lt;label for="description"&gt;Description&lt;/label&gt;
      &lt;td&gt;&lt;input type="text" name="description" value="" id="description" class="required text" title="Please, fill in your zipcode" data-required="true"&gt;&lt;br /&gt;
      &lt;label for="location"&gt;Location&lt;/label&gt;&lt;input type="text" name="location" value="" id="location" class="text" title="Please, fill in your state"&gt; &lt;br /&gt;
      &lt;p&gt;
          &lt;input type="submit" value="Send"/&gt; &lt;input type="reset" /&gt;
      &lt;/p&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And this is my <code>crmlead.php</code> client code:</p>
  
  <pre><code>&lt;?php
  
  include("xmlrpc.inc");      
  
  class Contact
  {
  private $subject = '', $to = '';
  
  function __construct($to, $sub)
  {
      $this-&gt;to = $to;
      $this-&gt;subject = $sub;
  }
  
  
  function xmlCallTo($usr, $password, $database, $server, $post)
  {
      $user = "admin";
      $pass = "admin";
      $db = "BMWE-001";
      $server_url = 'http://localhost:8069/xmlrpc/'; 
  
      $client = new xmlrpc_client($server_url.'common');
  
      $msg = new xmlrpcmsg('login');
      $msg-&gt;addParam(new xmlrpcval($db, "string"));
      $msg-&gt;addParam(new xmlrpcval($user, "string"));
      $msg-&gt;addParam(new xmlrpcval($pass, "string"));
  
  
      $res =  &amp;$client-&gt;send($msg);
  
      if(!$res-&gt;faultCode()){
  
          $val = $res-&gt;value();   
          $id = $val-&gt;scalarval();
  
          if (empty($id)){
  
              echo "Connection error = ";
              exit;
          }
          else
          {
  
              $val = $res-&gt;value()-&gt;scalarval();
  
              $val = array ("name" =&gt; new xmlrpcval($post["New Lead","string"),
                            "email_from" =&gt; new xmlrpcval($post['email'], "string"),
                            "phone" =&gt; new xmlrpcval($post['phone'], "string"),
                            "partner_name" =&gt; new xmlrpcval($post['partner_name'], "string"),
                "event_date" =&gt; new xmlrpcval($post['event_date'], "string"),
                            "guests" =&gt; new xmlrpcval($post['guests'], "string"),
                            "location" =&gt; new xmlrpcval($post['location'], "string"),
                            "budget" =&gt; new xmlrpcval($post['budget'], "string"),
                            "stage_id" =&gt; new xmlrpcval(2, "int"),
                            "state" =&gt; new xmlrpcval("draft", "string"),
                            "description" =&gt; new xmlrpcval($post['description'], "string")
                          );
  
              $msg = new xmlrpcmsg('execute');
              $msg-&gt;addParam(new xmlrpcval($db, "BMWE-001"));
              $msg-&gt;addParam(new xmlrpcval($id, "1"));
              $msg-&gt;addParam(new xmlrpcval($pass, "admin"));
              $msg-&gt;addParam(new xmlrpcval("crm.lead", "string"));
              $msg-&gt;addParam(new xmlrpcval("create", "string"));
              $msg-&gt;addParam(new xmlrpcval($val, "struct"));
  
  
              $res2 = &amp;$client2-&gt;send($msg);
  
              if(!$res2-&gt;faultCode())
              {
                  $readVal = $res2-&gt;value()-&gt;scalarval();
  
                  }
                  else
                  {
                      echo "&lt;br /&gt;Lead is not created";
                  }
              }
              else
              {
                  echo "&lt;br /&gt;Problem in message sending for create lead";
              }
          }           
      }
      else
      {
          echo "&lt;br /&gt;Connection not established";
      }
  }
  }
  exit;
  ?&gt;
  </code></pre>
  
  <p>Both of these Scripts run on same server, on localhost, thru <code>nginx</code> the php configuration runs just fine, so, nginx server is ok on that part.</p>
  
  <p>And Odoo v8 is running on same machine, independently, localhost also, obviously.</p>