Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Web service with PHP and OPENERP 7.0 Please need help...

By
Odoo
on 5/21/14, 4:18 AM 843 views

project.php file

***********In PHP**********888

I create one php form with two fields

name

phone number

and a submit button

click on submit data is added into mysql database

***********OPENERP**************************

In My Custom OPENERP Module i have---

In openerp i have to create a module for student information

it contains

name

phone number

in a form view and two buttons added 1)import students 2)export students

import students button-data added from php site to openerp.

export students button- data added from openerp to php--

FOr this one how to connect this with xmlrpc for web service

 

-------------------here I attached my code sample---------

PHP

 

1)index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
 
<body>
<form action="insert.php" method="post">
Firstname: <input type="text" name="fname" /><br><br>
Phone: <input type="text" name="phone" /><br><br>
 
<input type="submit" />
</form>
</body>
</html>

insert.php

<?php
$con = mysql_connect("localhost","root","siroco");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("project", $con);
 
$sql="INSERT INTO info (name, phone)
VALUES
('$_POST[fname]','$_POST[lname]')";
 
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";
 
 
$res=  mysql_query("SELECT * FROM info");  
if(mysql_query($sql,$con))
{
  echo "<table border='1'><tr><th>Name</th><th>Phone</th></tr>";
while($row = mysql_fetch_array($res))
{
 echo "<tr>";
   echo "<td>" . $row['name'] . "</td>";
    echo "<td>" . $row['phone'] . "</td>";
        echo "</tr>";
   }
   }
 
mysql_close($con)
?>

-------------------------------------------------------opeenrp-------------module

init.py

import web_service_info

openerp.py

{
    "name" : "Web service module",
    "version" : "1.0",
    "author" : "ME ",
    "category" : "Generic Modules for Web service connector",
    "description": """
    Module For Managing Student Name and roll number export and import:
 
    """,
    "depends" : ['base'],
    "init_xml" : [],
    'images': [],

     "update_xml" : [
                    'web_service_view.xml'           
         ],
                   
    'images': [],
    "installable": True,
    "auto_install":False
}

3)webinfo.py

from osv import osv,fields

class student_info(osv.osv):
    
    _name='student.info'
    
    _columns={
               'name':fields.char('name',size=15),
               'phone_number':fields.char('Phonenumber',size=10),
             }
    def import_student(self,cr,uid,ids,context=None):
        print "######################context#######",context
        return "Hi"
    def export_student(self,cr,uid,ids,context=None):
        print "#########3uid#######",ids
        return "Hi"
    
student_info()

4)webinfo.xml

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
    
    
     <record id="user_info_tree_view" model="ir.ui.view">
          <field name="name">user.info.tree.view</field>
          <field name="model">student.info</field>
          <field name="type">tree</field>
            <field name="arch" type="xml">
             <tree string="user information">
                <field name="name"/>
                <field name="phone_number"/>
              </tree>
       </field>
       </record>
       
        <record id="project_info_form_view" model="ir.ui.view">
            <field name="name">project.info.form.view</field>
            <field name="model">student.info</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
            <form string="Project information" version="7.0" >
                
                <header>
                                        
                    <button name="import_student" string="Import Student"
                 class="oe_highlight" type="object"/>

                    <button name="export_student" string="Export Student"
                 class="oe_highlight" type="object"/>

                </header>        
                
                    <sheet>
                   <group>
                        <field name="name"/>
                     <field name="phone_number"/></group>    
                     </sheet>   
                </form>
                
            </field>
        </record>
        
           <record id="hr_info_action" model="ir.actions.act_window">
               <field name="name">HR Details</field>
               <field name="res_model">student.info</field>
               <field name="view_type">form</field>
               <field name="view_mode">tree,form</field>
       </record>


       <menuitem id="user_module_menu" name="Student Info"/>
       
       <menuitem id="user_module_menu1"  parent="user_module_menu" name="Student Information"/>
       
       <menuitem id="user_module_menu123" action="hr_info_action" parent="user_module_menu1" name="Student Details"/>
     
    </data>
</openerp>

 

 

 

 

 

 

 

0

Nehal

--Nehal--
2090
| 5 2 8
Ahmadabad, India
--Nehal--
Nehal
On 5/21/14, 5:49 AM

Hi,

Following link may help you:

https://doc.openerp.com/6.0/developer/6_22_XML-RPC_web_services/

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/21/14, 4:18 AM
Seen: 843 times
Last updated: 3/16/15, 8:10 AM