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.
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: