Skip to Content
Menu
This question has been flagged
2 Replies
9179 Views

Hello, 

I am new to odoo. I am using the c# OdooRpcWrapper to get list of products from Odoo.On a test database, I can connect to Odoo successfully and it is finding my 3 products but I am not getting there names, price etc. What field names should i use to get Product name, Price etc- Is there anywhere I get list of field names for different tables in Odoo?

Thanks a lot,

Vikram

Avatar
Discard
Best Answer

Hi Vikram,

From my thoughts, You are getting the objects if the products. So please try to populate the fields from these objects by using dot operator. It could be better if you can share what you are getting in your first call.

Avatar
Discard
Author Best Answer

Thanks Nilmar,

Below is my code:

OdooAPI api = new OdooAPI(creds);

OdooModel productmodel = api.GetModel("product.template");

object[] filter = new object[1];

filter[0] = new object[3] { "name", "!=", null};

List<OdooRecord> records = productmodel.Search(filter);

foreach (OdooRecord record in records)

{

listBox1.Items.Add(String.Format("[{0}] {1} {2}", record.GetValue("cost"), record.GetValue("product_code"), record.GetValue("name")));

}

What I am getting is [] for the three products.

Thanks,

VIkram


Hello Nilmar,

How do I do what you are asking me? (console the product records). This is what I get on Console:

System.Collections.Generic.List`1[OdooRpcWrapper.OdooRecord]


OK Got it.

I had missed this line in my program:

productModel.AddField("name"); productModel.AddField("default_code");
It is only then that you can retrieve these fields.

Thanks a lot.



Avatar
Discard

Can you just console Odoo product records before the looping?