如何在python控制台中运行Odoo ORM方法? [英] How to run Odoo ORM methods in the python console?

查看:206
本文介绍了如何在python控制台中运行Odoo ORM方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在python控制台中使用ORM方法,例如浏览搜索

I would like to use ORM methods such as browse or search in the python console.

$pwd
/opt/odoo/

$python
>>> import openerp
>>> product_obj = pool.get('product.product)
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
NameError: name 'pool' is not defined

我怎样才能实现?

推荐答案

在版本9中,您可以使用 odoo.py shell启动odoo shell -d< database> ,感谢此提交

In version 9 you can start an odoo shell with odoo.py shell -d <database>, thanks to this commit

在版本8中,功能不是内置的,但您可以使用此脚本此模块 OERPLib

In version 8 the functionality is not builtin but you can use this script, this module, or OERPLib

这篇关于如何在python控制台中运行Odoo ORM方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆