Reputation: 365
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.
Upvotes: 1
Views: 1388
Reputation: 365
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:
Upvotes: 1
Reputation: 101
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.
Upvotes: 0