1

I'm trying to insert a new client record in Odoo8 PostrgreSQL database using c#.

To connect with PostgreSQL database from c# , i use npgsql.

here is my Insert command

cmd.CommandText = "INSERT INTO res_partner (name,email,notify_email ,active) VALUES ('user name','[email protected]','[email protected]'," + true + ")";

I'm able to see the new insert record in res_partner table using pgAdmin, but using Odoo , i'm not able to see the new client.

2 Answers 2

1

Odoo has a Web Service api which is better to use to interact with external application. With a little research, I found that interesting wrapper: OdooRpcWrapper . I used it in my application and everything works fine. I'm now able to see new added client from c# in Odoo8.

Code to add new client:

OdooConnectionCredentials creds = new OdooConnectionCredentials("http://localhost:8069", "your_bd", "admin", "admin");
OdooAPI api = new OdooAPI(creds);
//Define what model you want to use
OdooModel partnerModel = api.GetModel("res.partner");
//Create new objects by calling the model. New objects need to be saved.
OdooRecord record = partnerModel.CreateNew();
record.SetValue("name", "Abdelaziz test");
record.Save();

Step to use it in asp.net Webforms application:

  1. Download OdooRpcWrapper from github
  2. add it to your project: right click on solution => add => existing project and select the wrapper
  3. add it as reference in your asp project: right click on reference => add reference => under solution tab, select OdooRpcWrapper project you added earlier
  4. use the code to add new client
Sign up to request clarification or add additional context in comments.

1 Comment

Could you add your web api call code for this partner insertion here?
0

Logically you can see changes in db in Odoo UI without using Odoo Web API

When you insert records in PostgreSQl db of odoo using webservice or manual from PgAdmin, you must insert values in all columns that not accept null to be reflected in odoo UI.

From pgadmin you can right click on a table, select properties to see which columns don't accept null.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.