Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

TypeError: 'bool' object has no attribute '__getitem__' in android

By
hanane
on 4/10/16, 1:17 PM 467 views

Guys please help this is my code 

Object[] l = { "is_company", "=", false }; 
Object[] filter = { l };
odoo = new OdooUtility("http://10.10.35.7:8069", "object"); 
SearchIdTask = odoo.exec(listner, "db","1","password","res.partner","search",filter);
and here is the exec method
public Long exec (XMLRPCCallback listner, String db, String uid, String password,String objects, String method, Object[] data){    
Long id = client.callAsync(listner,"execute_kw",db,Integer.parseInt(uid),password,objects,method,data);
return id;
}

pls I've been looking at this for hours i think there is something wrong with the filter :'(

hanane
on 4/10/16, 1:19 PM
0
hanane
On 4/10/16, 6:01 PM

Thank you so much for your answer but i still get the same error, i'm affraid if i try the second code it wont work bc xmlrpc in android doesn't work well because i'm using a light weight library called aXMLRPC that was develppd by someone in github

0

Hardikgiri Goswami

--Hardikgiri Goswami--
1123
| 2 1 5
Rajkot, India
--Hardikgiri Goswami--

OpenERP/Odoo Customization/Integration Expert / Python Programmer

Skype ID : hardikgiri.goswami

Hardikgiri Goswami
On 4/10/16, 4:55 PM

Hi Hanane,

In your code Object Array should be define as follow:

Object[] l = new Object[]{ "is_company", "=", false};
Object[] filter = new Object[]{l};

You can try following working code for java :

package odoo.java;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
public class JavaOdoo {
public static void main(String[] args){
final XmlRpcClient client = new XmlRpcClient();
Object[] emptyList = new Object[]{};
final String url = "http://192.168.153.128:8069";
final String db = "demo_80";
final String username = "admin";
final String password = "a";
System.out.print("Hello World");
final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
try {
common_config.setServerURL(
new URL(String.format("%s/xmlrpc/2/common", url)));
client.execute(common_config, "version", emptyList);
int uid = (int)client.execute(
common_config, "authenticate", new Object[]{db, username, password, emptyList});
System.out.print(uid);
final XmlRpcClient models = new XmlRpcClient() {{
setConfig(new XmlRpcClientConfigImpl() {{
setServerURL(new URL(String.format("%s/xmlrpc/2/object", url)));
}});
}};
Object[] res = (Object[]) models.execute("execute_kw", new Object[]{
db, uid, password,
"res.partner", "search",
new Object[]{new Object[]{
new Object[]{"is_company", "=", false}}}
});
                         // printing ids of partner which have is_company false.
for(int i=0;i<res.length;i++){
System.out.println(res[i]);
}
} catch (XmlRpcException | MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}



Regards,

Hardikgiri Goswami

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/10/16, 1:17 PM
Seen: 467 times
Last updated: 4/10/16, 6:01 PM