openerp增加交互环境shell.py脚本
来源:互联网 发布:淘宝联系卖家的电话 编辑:程序博客网 时间:2024/05/02 04:05
依赖ipython
在工程环境下建立配置文件openerp-server.conf
[options]admin_passwd = admindb_host = localhostdb_port = 5432db_user = usernamedb_password = passworddb_name=dbname
在工程目录下增加shell.py 保存如下内容
# -*- coding: utf-8 -*-import sysimport osimport loggingimport ConfigParserfrom openerp.modules.registry import RegistryManagerfrom IPython import embed_logger = logging.getLogger(__name__)# 添加项目目录到环境变量 为了导入openerpopenerp_path = os.getcwd()sys.path.insert(0, openerp_path)import openerp# 读取数据库连接配置db_config = ConfigParser.ConfigParser()with open('%s/openerp-server.conf' % openerp_path) as conf: db_config.readfp(conf) config = openerp.tools.config config['db_password'] = db_config.get('options', 'db_password') config['db_user'] = db_config.get('options', 'db_user') config['db_name'] = db_config.get('options', 'db_name') config['db_port'] = db_config.get('options', 'db_port')def shell_script(): uid, context = 1, None registry = RegistryManager.get(config['db_name']) with registry.cursor() as cr: user = registry.get('res.users').browse(cr, 1, 1) class Dummy_self(object): """为了和OE统一方便调用 造一个假的self.pool""" pool = registry self = Dummy_self() embed()if __name__ == '__main__': """ 依赖 sudo easy_install ipython #sudo easy_install readline 交互环境运行 python shell.py 使用列子 self.pool.get('res.users') """ shell_script()
运行交互环境
python shell.py
0 0
- openerp增加交互环境shell.py脚本
- shell && sql 交互脚本
- openerp __openerp__.py 总结
- 增加系统安全的shell脚本
- shell脚本增加回车符
- shell脚本批量增加用户
- shell : 基本的交互脚本
- shell脚本--交互
- shell-ftp交互下载脚本
- Openerp命令行接口:odoo.py
- shell 脚本增加smb用户及密码
- Shell 增加server rsync 控制脚本
- linux shell脚本三种交互方法
- Linux Shell脚本实现自动交互
- shell脚本与Oracle交互方式
- shell脚本内与mysql交互
- shell脚本与Oracle交互方式
- 程序和shell脚本交互方法
- php 5.3新增的闭包语法介绍function() use() {}
- 【分享】Spring2.5 注解介绍(3.0通用)
- Broadcast Receiver
- js脚本类库(lib)之日期时间处理
- Eclipse 如何修改工程(project)名称
- openerp增加交互环境shell.py脚本
- 不要小看它们 这些能让你越来越美
- C#字符串的加密与解密(DES和TripleDES算法的加密解密过程)
- java面向接口编程
- tomcat重定向方法
- Ubuntu10.10的网络配置
- ios远程推送笔记
- 多平台响应键盘事件!(适用于Cocos2dx 3.0 alpha以上版本)
- JSTL