【Odoo】Odoo_CRM数据操作
2015-12-03 08:51
423 查看
关于Odoo
对Odoo进行操作主要使用三个jar包
如下:
xmlrpc-client
xmlrpc-common
xmlrpc-server
1.数据添加
public static void CreatImage(Context mContext,int x,Odoo odoo,OUser ouser,Row row) throws Exception {
Odoo mOdoo=odoo;
OUser mOUser=ouser;
String all_url=mOdoo.getServerURL();
String[] group=all_url.split(“:”);
String port=group[group.length-1];
String host=ouser.getHost();
String dbName=ouser.getDatabase();
String userName=ouser.getUsername();
String password=ouser.getPassword();
AppGlobal.setHostname(host);
AppGlobal.setPort(Integer.parseInt(port));
AppGlobal.setDbname(dbName);
AppGlobal.setUsername(userName);
AppGlobal.setPassword(password);
Session ss = new Session(
OpenERPXmlRpcProxy.RPCProtocol.RPC_HTTP, AppGlobal
.getHostname(), AppGlobal.getPort(), AppGlobal
.getDbname(), AppGlobal.getUsername(),
AppGlobal.getPassword());
AppGlobal.setOesession(ss);
Session s=AppGlobal.getOesession();
ObjectAdapter oa = new ObjectAdapter(s, “visbp.baoshui”);
oa.createObject(row);
}
2.数据查看
public static RowCollection getImageByName(Context mContext,String Name,Odoo odoo,OUser ouser) throws Exception {
Odoo mOdoo=odoo;
OUser mOUser=ouser;
String all_url=mOdoo.getServerURL();
String[] group=all_url.split(“:”);
String port=group[group.length-1];
String host=ouser.getHost();
String dbName=ouser.getDatabase();
String userName=ouser.getUsername();
String password=ouser.getPassword();
AppGlobal.setHostname(host);
AppGlobal.setPort(Integer.parseInt(port));
AppGlobal.setDbname(dbName);
AppGlobal.setUsername(userName);
AppGlobal.setPassword(password);
Session ss = new Session(
OpenERPXmlRpcProxy.RPCProtocol.RPC_HTTP, AppGlobal
.getHostname(), AppGlobal.getPort(), AppGlobal
.getDbname(), AppGlobal.getUsername(),
AppGlobal.getPassword());
// set the session in the global static instance.
AppGlobal.setOesession(ss);
Session s = AppGlobal.getOesession();
s.startSession();
ObjectAdapter oa = new ObjectAdapter(s, “xiao.account.image”);
String[] fields = { “name” ,”image” };
FilterCollection filters = new FilterCollection();
filters.add(“name”, “=”, Name);
RowCollection rc = oa.searchAndReadObject(filters, fields);
return rc;
}
3.数据修改
public static void UpdateImage(Odoo odoo,OUser ouser,Object o) throws Exception {
Odoo mOdoo=odoo;
OUser mOUser=ouser;
String all_url=mOdoo.getServerURL();
String[] group=all_url.split(“:”);
String port=group[group.length-1];
String host=ouser.getHost();
String dbName=ouser.getDatabase();
String userName=ouser.getUsername();
String password=ouser.getPassword();
AppGlobal.setHostname(host);
AppGlobal.setPort(Integer.parseInt(port));
AppGlobal.setDbname(dbName);
AppGlobal.setUsername(userName);
AppGlobal.setPassword(password);
Session ss = new Session(
OpenERPXmlRpcProxy.RPCProtocol.RPC_HTTP, AppGlobal
.getHostname(), AppGlobal.getPort(), AppGlobal
.getDbname(), AppGlobal.getUsername(),
AppGlobal.getPassword());
AppGlobal.setOesession(ss);
Session s=AppGlobal.getOesession();
ObjectAdapter oa = new ObjectAdapter(s, “visbp.baoshui”);
oa.getNewRow(new String[]{“id”,”name”}).put(“name”,”“+o);
}
4.数据删除
public static boolean DeleteImage(Context mContext,int x,Odoo mOdoo,OUser ouser) throws Exception {
String all_url=mOdoo.getServerURL();
String[] group=all_url.split(“:”);
String port=group[group.length-1];
String host=ouser.getHost();
String dbName=ouser.getDatabase();
String userName=ouser.getUsername();
String password=ouser.getPassword();
AppGlobal.setHostname(host);
AppGlobal.setPort(Integer.parseInt(port));
AppGlobal.setDbname(dbName);
AppGlobal.setUsername(userName);
AppGlobal.setPassword(password);
Session ss = new Session(
OpenERPXmlRpcProxy.RPCProtocol.RPC_HTTP, AppGlobal
.getHostname(), AppGlobal.getPort(), AppGlobal
.getDbname(), AppGlobal.getUsername(),
AppGlobal.getPassword());
AppGlobal.setOesession(ss);
Session s = AppGlobal.getOesession();
s.startSession();
ObjectAdapter oa = new ObjectAdapter(s, “xiao.account.image”);
String[] fields = { “id”};
FilterCollection filters = new FilterCollection();
filters.add(“id”, “=”, x);
Row row=oa.searchAndReadObject(filters,fields).get(0);
boolean fg=oa.unlinkObject(row);
return fg;
}
对Odoo进行操作主要使用三个jar包
如下:
xmlrpc-client
xmlrpc-common
xmlrpc-server
1.数据添加
public static void CreatImage(Context mContext,int x,Odoo odoo,OUser ouser,Row row) throws Exception {
Odoo mOdoo=odoo;
OUser mOUser=ouser;
String all_url=mOdoo.getServerURL();
String[] group=all_url.split(“:”);
String port=group[group.length-1];
String host=ouser.getHost();
String dbName=ouser.getDatabase();
String userName=ouser.getUsername();
String password=ouser.getPassword();
AppGlobal.setHostname(host);
AppGlobal.setPort(Integer.parseInt(port));
AppGlobal.setDbname(dbName);
AppGlobal.setUsername(userName);
AppGlobal.setPassword(password);
Session ss = new Session(
OpenERPXmlRpcProxy.RPCProtocol.RPC_HTTP, AppGlobal
.getHostname(), AppGlobal.getPort(), AppGlobal
.getDbname(), AppGlobal.getUsername(),
AppGlobal.getPassword());
AppGlobal.setOesession(ss);
Session s=AppGlobal.getOesession();
ObjectAdapter oa = new ObjectAdapter(s, “visbp.baoshui”);
oa.createObject(row);
}
2.数据查看
public static RowCollection getImageByName(Context mContext,String Name,Odoo odoo,OUser ouser) throws Exception {
Odoo mOdoo=odoo;
OUser mOUser=ouser;
String all_url=mOdoo.getServerURL();
String[] group=all_url.split(“:”);
String port=group[group.length-1];
String host=ouser.getHost();
String dbName=ouser.getDatabase();
String userName=ouser.getUsername();
String password=ouser.getPassword();
AppGlobal.setHostname(host);
AppGlobal.setPort(Integer.parseInt(port));
AppGlobal.setDbname(dbName);
AppGlobal.setUsername(userName);
AppGlobal.setPassword(password);
Session ss = new Session(
OpenERPXmlRpcProxy.RPCProtocol.RPC_HTTP, AppGlobal
.getHostname(), AppGlobal.getPort(), AppGlobal
.getDbname(), AppGlobal.getUsername(),
AppGlobal.getPassword());
// set the session in the global static instance.
AppGlobal.setOesession(ss);
Session s = AppGlobal.getOesession();
s.startSession();
ObjectAdapter oa = new ObjectAdapter(s, “xiao.account.image”);
String[] fields = { “name” ,”image” };
FilterCollection filters = new FilterCollection();
filters.add(“name”, “=”, Name);
RowCollection rc = oa.searchAndReadObject(filters, fields);
return rc;
}
3.数据修改
public static void UpdateImage(Odoo odoo,OUser ouser,Object o) throws Exception {
Odoo mOdoo=odoo;
OUser mOUser=ouser;
String all_url=mOdoo.getServerURL();
String[] group=all_url.split(“:”);
String port=group[group.length-1];
String host=ouser.getHost();
String dbName=ouser.getDatabase();
String userName=ouser.getUsername();
String password=ouser.getPassword();
AppGlobal.setHostname(host);
AppGlobal.setPort(Integer.parseInt(port));
AppGlobal.setDbname(dbName);
AppGlobal.setUsername(userName);
AppGlobal.setPassword(password);
Session ss = new Session(
OpenERPXmlRpcProxy.RPCProtocol.RPC_HTTP, AppGlobal
.getHostname(), AppGlobal.getPort(), AppGlobal
.getDbname(), AppGlobal.getUsername(),
AppGlobal.getPassword());
AppGlobal.setOesession(ss);
Session s=AppGlobal.getOesession();
ObjectAdapter oa = new ObjectAdapter(s, “visbp.baoshui”);
oa.getNewRow(new String[]{“id”,”name”}).put(“name”,”“+o);
}
4.数据删除
public static boolean DeleteImage(Context mContext,int x,Odoo mOdoo,OUser ouser) throws Exception {
String all_url=mOdoo.getServerURL();
String[] group=all_url.split(“:”);
String port=group[group.length-1];
String host=ouser.getHost();
String dbName=ouser.getDatabase();
String userName=ouser.getUsername();
String password=ouser.getPassword();
AppGlobal.setHostname(host);
AppGlobal.setPort(Integer.parseInt(port));
AppGlobal.setDbname(dbName);
AppGlobal.setUsername(userName);
AppGlobal.setPassword(password);
Session ss = new Session(
OpenERPXmlRpcProxy.RPCProtocol.RPC_HTTP, AppGlobal
.getHostname(), AppGlobal.getPort(), AppGlobal
.getDbname(), AppGlobal.getUsername(),
AppGlobal.getPassword());
AppGlobal.setOesession(ss);
Session s = AppGlobal.getOesession();
s.startSession();
ObjectAdapter oa = new ObjectAdapter(s, “xiao.account.image”);
String[] fields = { “id”};
FilterCollection filters = new FilterCollection();
filters.add(“id”, “=”, x);
Row row=oa.searchAndReadObject(filters,fields).get(0);
boolean fg=oa.unlinkObject(row);
return fg;
}
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories