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[]"
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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[]"
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;
}
}
Create an account today to enjoy exclusive features and engage with our awesome community!
Přihlásit se
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 .