Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
3375 Widoki

Hi,

Please i want to know how i can get the partner_id.id in model "account.invoice" using xml rpc in C#. I can easily retrieve the others fields but when i try to retrieve a related field i get "System.Object[]"

Awatar
Odrzuć

Hi Chacha,

I have the same problem, i'm trying to retrieve information from a model that uses information from another model using xml rpc in C#, and i get "System.Object[]". Did you find any solution ? 

Thank you .

Najlepsza odpowiedź

This is an old question, but I had the same issue, found the answer, so thought I'd share it here for others.

I'm using https://github.com/ieski/OdooXmlRpc as the core, but re-engineered to use .Net 4.8. Behind that is Cook.Computing XmlRPCV2 (from nuget).


Basically, the Many2one is an object array, so you need to cast it and assign the value to a new field, at least that was my solution.

The state name in the many2one returned something like Victoria(AU), which doesn't look very good, so I used the GetStateCode method to return the code from Odoo model.

               Object[] state = (Object[])oa.GetField("state_id").Value;
address.State = OdooClient.GetStateCode(Int32.Parse(state[0].ToString()));

public string GetStateCode(int StateId)
{
List results = new List();
try
{
var rpcContext = new RpcContext(_OdooConn, "res.country.state");
rpcContext
.RpcFilter
.Equal("id", StateId);
results = rpcContext.Execute(true).ToList();
return results.FirstOrDefault().GetField("code").Value.ToString();
}
catch
{
return string.Empty;
}
}
Awatar
Odrzuć