Odoo中文社区可以通过以下三个域名访问:shine-it.net , odoocn.org,odoo.net.cn

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

Windows下 如何用PyCharm运行调试 Odoo 8.0



  • 作为新手,能够单步执行调试源代码是个很好的学习过程。 花了一天时间,终于成功用PyCharm运行最新的Odoo 8.0 版本。 <br /><br />***** 新手犯了一个低级的错误,发现[b]Odoo在Windows下不能正常运行[/b]。  建议大家不要尝试了。 留这个帖子引以为戒。  **********<br /><br />原文在 [url=http://www.mindissoftware.com/2014/09/08/Odoo-PyCharm-Windows-installation/]http://www.mindissoftware.com/2014/09/08/Odoo-PyCharm-Windows-installation/[/url]<br /><br />Debug Odoo using PyCharm in Windows<br />08 Sep 2014<br />This blog describes how to setup PyCharm to run/debug Odoo in Windows environment. I use PyCharm Professional 3.4 in 64-bit Windows 8 to run/debug Odoo 8.0 branch. This blog has three parts. The first part describes how to install required packages. The second part shows how to configure PostgreSQL and Odoo. The third part gives problems and their solutions during my installation process.<br /><br />I. Install packages and source code<br />1. Get Odoo source code and change branch to 8.0<br />git clone https://github.com/odoo/odoo.git<br />git checkout 8.0<br />2. Install Visual Studio if you don't have one.<br />The free Visual Studio Express is enough to compile and install Python packages in later steps. To avoid "error: Unable to find vcvarsall.bat", I need to set the following environment variable in "cmd" command line:<br /><br />If you have Visual Studio 2013 installed (Visual Studio Version 12), execute SET VS90COMNTOOLS=%VS120COMNTOOLS%.<br /><br />For Visual Studio 2012 (Visual Studio Version 11), execute SET VS90COMNTOOLS=%VS110COMNTOOLS%.<br /><br />For Visual Studio 2010, execute SET VS90COMNTOOLS=%VS100COMNTOOLS%.<br /><br />3. Install required packages from a binary source<br />With 64-bit Python 2.7.8 installed, I had some compiling errors in installing some required packages for Odoo. Tired of fixing them, I just installed the following pre-compiled Windows 64-bit binary packages from http://www.lfd.uci.edu/~gohlke/pythonlibs<br /><br />Pillow<br />lxml<br />psycopg2<br />python-ldap<br />pywin32<br />There are installable windows files for them. Carefully select each file that matches your 32-bit/64-bit and Python version, download and execute the file to install it.<br /><br />4. Create a virtual environment<br />This is optional but it's a good idea to use a virtual environment.<br /><br />In PyCharm, open the odoo folder to create a new project.<br />Then in File --> Setting --> Project Setting (top left panel) --> Project Interpreter, click the tool icon on the top right, then select "Create Virtual Environment". In the dialog, give the new environment a name such as "odoo8", remember the location, choose base interpreter, click both check-boxes (Inherit global site-packages, Make available to all projects). Finally click OK to create it.<br /><br />You should see some packages such as pip, psycopg2, python-ldap, pywin32 and setuptools. It is a good idea to upgrade pip and setuptools.<br />Select pip, then the up-arrow icon on the right side to upgrade it. Do the same to upgrade setuptools.<br /><br />5. Copy and edit requirments.txt<br />Copy requirements.txt from the root of Odoo source repository to the location of your virtual environment. With the above configuration, it is C:\Users\your-username\odoo8&quot;. Edit the file to remove the following lines<br /><br />Pillow==2.5.1<br /><br />lxml==3.3.5<br /><br />psycopg2==2.5.3<br /><br />python-ldap==2.4.15<br />6. Batch install packages from requirments.txt<br />In the &quot;cmd&quot; window that has the correct setting of VS90COMNTOOLS, go to the location of your virtual environment. By default, it isC:\Users\username\odoo8". execute<br /><br />.\Scripts\activate.bat<br />pip -r requirements.txt<br />The above commands activate the virtual environment and install all required packages for Odoo. Please pay attention to the output of any error message. The output is also stored in a pip log file C:\Users\your-username\pip\pip.log. You can ignore warning messages. pip stops when there is an error.<br /><br />Restart your PyCharm and you should see all packages in the newly created environment. Make this environment the interpreter of your Odoo project. You are able to run openerp-server.py file.<br /><br />However, you still need to install Postgresql and configure the Odoo to work with it.<br /><br />II. Install PostgreSQL and configure Odoo<br />1. Download and install PostgreSQL for Windows.<br />2. Create a new role with superuser privilege for Odoo application.<br />In my case, I create a superuser "odoo" and set its password as "odoo".<br /><br />3. Check PostgreSQL configuration<br />You do not need to change anything because default configuration works correctly as a local database. However, if there is any errors, you can check the the two configuration files of PostgreSQL . Both can be edited using Tools --> Server Configuration menu in pgAdmin.<br /><br />In postgresql.conf, make sure that listen_addresses are enabled. It is checked by default.<br /><br />In pg_hba.conf, enable the "host all all 127.0.0.1/32 md5". It means localhost can be connected with a role name and password. It is checked by default.<br /><br />4. Config Odoo<br />In Odoo project root, copy debian/openerp-server.conf to another folder. In my case, it is D:\Dev\odooTest\openerp-server.conf , edit the file to have the following configurations:<br /><br />[options]<br />; This is the password that allows database operations:<br />; admin_passwd = admin<br />db_host = localhost<br />db_port = 5432<br />db_user = odoo<br />db_password = odoo<br />addons_path = D:\Dev\PyCharmProjects\odoo\addons<br />In the addons_path option, set it to the addons directory in your Odoo project root.<br /><br />Then in PyCharm menu Run --> Edit Configurations, click "+" on the top left to create a new configuration with the following settings:<br /><br />Name: Odoo8 Single instance checkbox: checked Script: D:\Dev\PyCharmProjects\odoo\openerp-server Script parameters: --config=D:\Dev\odooTest\openerp-server.conf<br /><br />Congratulations, you should be able to run and debug Odoo !!!<br /><br />III. Issues and solutions<br />When install packages from requirements.txt, there is an message "error: Unable to find vcvarsall.bat". Setting VS90COMNTOOLS to correct Visual Studio path fixed it.<br /><br />Packages such as lxml, psycopg2, python-ldap had many compile errors. The solution is downloading and installing binary packages from http://www.lfd.uci.edu/~gohlke/pythonlibs.<br /><br />The Pillow package did work correctly because of an error of 'decoder zip not available'. Again, installing binary package fixed it.<br /><br />You may need to drop the newly created database if something is wrong when you run Odoo to create the initial database. There might be some garbage left in the database and you see an error message like "QWebTemplateNotFound: External ID not found in the system: web.login"



  • 作为新手,能够单步执行调试源代码是个很好的学习过程。 花了一天时间,终于成功用PyCharm运行最新的Odoo 8.0 版本。 <br /><br />***** 新手犯了一个低级的错误,发现[b]Odoo在Windows下不能正常运行[/b]。  建议大家不要尝试了。 留这个帖子引以为戒。  **********<br /><br />原文在 [url=http://www.mindissoftware.com/2014/09/08/Odoo-PyCharm-Windows-installation/]http://www.mindissoftware.com/2014/09/08/Odoo-PyCharm-Windows-installation/[/url]<br /><br />Debug Odoo using PyCharm in Windows<br />08 Sep 2014<br />This blog describes how to setup PyCharm to run/debug Odoo in Windows environment. I use PyCharm Professional 3.4 in 64-bit Windows 8 to run/debug Odoo 8.0 branch. This blog has three parts. The first part describes how to install required packages. The second part shows how to configure PostgreSQL and Odoo. The third part gives problems and their solutions during my installation process.<br /><br />I. Install packages and source code<br />1. Get Odoo source code and change branch to 8.0<br />git clone https://github.com/odoo/odoo.git<br />git checkout 8.0<br />2. Install Visual Studio if you don't have one.<br />The free Visual Studio Express is enough to compile and install Python packages in later steps. To avoid "error: Unable to find vcvarsall.bat", I need to set the following environment variable in "cmd" command line:<br /><br />If you have Visual Studio 2013 installed (Visual Studio Version 12), execute SET VS90COMNTOOLS=%VS120COMNTOOLS%.<br /><br />For Visual Studio 2012 (Visual Studio Version 11), execute SET VS90COMNTOOLS=%VS110COMNTOOLS%.<br /><br />For Visual Studio 2010, execute SET VS90COMNTOOLS=%VS100COMNTOOLS%.<br /><br />3. Install required packages from a binary source<br />With 64-bit Python 2.7.8 installed, I had some compiling errors in installing some required packages for Odoo. Tired of fixing them, I just installed the following pre-compiled Windows 64-bit binary packages from http://www.lfd.uci.edu/~gohlke/pythonlibs<br /><br />Pillow<br />lxml<br />psycopg2<br />python-ldap<br />pywin32<br />There are installable windows files for them. Carefully select each file that matches your 32-bit/64-bit and Python version, download and execute the file to install it.<br /><br />4. Create a virtual environment<br />This is optional but it's a good idea to use a virtual environment.<br /><br />In PyCharm, open the odoo folder to create a new project.<br />Then in File --> Setting --> Project Setting (top left panel) --> Project Interpreter, click the tool icon on the top right, then select "Create Virtual Environment". In the dialog, give the new environment a name such as "odoo8", remember the location, choose base interpreter, click both check-boxes (Inherit global site-packages, Make available to all projects). Finally click OK to create it.<br /><br />You should see some packages such as pip, psycopg2, python-ldap, pywin32 and setuptools. It is a good idea to upgrade pip and setuptools.<br />Select pip, then the up-arrow icon on the right side to upgrade it. Do the same to upgrade setuptools.<br /><br />5. Copy and edit requirments.txt<br />Copy requirements.txt from the root of Odoo source repository to the location of your virtual environment. With the above configuration, it is C:\Users\your-username\odoo8&quot;. Edit the file to remove the following lines<br /><br />Pillow==2.5.1<br /><br />lxml==3.3.5<br /><br />psycopg2==2.5.3<br /><br />python-ldap==2.4.15<br />6. Batch install packages from requirments.txt<br />In the &quot;cmd&quot; window that has the correct setting of VS90COMNTOOLS, go to the location of your virtual environment. By default, it isC:\Users\username\odoo8". execute<br /><br />.\Scripts\activate.bat<br />pip -r requirements.txt<br />The above commands activate the virtual environment and install all required packages for Odoo. Please pay attention to the output of any error message. The output is also stored in a pip log file C:\Users\your-username\pip\pip.log. You can ignore warning messages. pip stops when there is an error.<br /><br />Restart your PyCharm and you should see all packages in the newly created environment. Make this environment the interpreter of your Odoo project. You are able to run openerp-server.py file.<br /><br />However, you still need to install Postgresql and configure the Odoo to work with it.<br /><br />II. Install PostgreSQL and configure Odoo<br />1. Download and install PostgreSQL for Windows.<br />2. Create a new role with superuser privilege for Odoo application.<br />In my case, I create a superuser "odoo" and set its password as "odoo".<br /><br />3. Check PostgreSQL configuration<br />You do not need to change anything because default configuration works correctly as a local database. However, if there is any errors, you can check the the two configuration files of PostgreSQL . Both can be edited using Tools --> Server Configuration menu in pgAdmin.<br /><br />In postgresql.conf, make sure that listen_addresses are enabled. It is checked by default.<br /><br />In pg_hba.conf, enable the "host all all 127.0.0.1/32 md5". It means localhost can be connected with a role name and password. It is checked by default.<br /><br />4. Config Odoo<br />In Odoo project root, copy debian/openerp-server.conf to another folder. In my case, it is D:\Dev\odooTest\openerp-server.conf , edit the file to have the following configurations:<br /><br />[options]<br />; This is the password that allows database operations:<br />; admin_passwd = admin<br />db_host = localhost<br />db_port = 5432<br />db_user = odoo<br />db_password = odoo<br />addons_path = D:\Dev\PyCharmProjects\odoo\addons<br />In the addons_path option, set it to the addons directory in your Odoo project root.<br /><br />Then in PyCharm menu Run --> Edit Configurations, click "+" on the top left to create a new configuration with the following settings:<br /><br />Name: Odoo8 Single instance checkbox: checked Script: D:\Dev\PyCharmProjects\odoo\openerp-server Script parameters: --config=D:\Dev\odooTest\openerp-server.conf<br /><br />Congratulations, you should be able to run and debug Odoo !!!<br /><br />III. Issues and solutions<br />When install packages from requirements.txt, there is an message "error: Unable to find vcvarsall.bat". Setting VS90COMNTOOLS to correct Visual Studio path fixed it.<br /><br />Packages such as lxml, psycopg2, python-ldap had many compile errors. The solution is downloading and installing binary packages from http://www.lfd.uci.edu/~gohlke/pythonlibs.<br /><br />The Pillow package did work correctly because of an error of 'decoder zip not available'. Again, installing binary package fixed it.<br /><br />You may need to drop the newly created database if something is wrong when you run Odoo to create the initial database. There might be some garbage left in the database and you see an error message like "QWebTemplateNotFound: External ID not found in the system: web.login"



  • 感谢分享,mark



  • 英文很头疼呀。。。



  • 请看另一片文章。。还有带有pdf,如果是绿色版  配置文件 复制到 source目录,并且修改addons的路径接<br /><br /><br /><br /><br />Pycharm 联合调试OpenERP服务端和客户端<br /><br />--------------------------------------------------<br />原创<br />1.绿色版如果用来开发。不要安装服务,就是不要点击service_install ,否则停止python-oe.exe也会马上自动运行了<br /><br />2. 把openerp-server.conf 复制到source,并修改 openerp-server.conf中的addons路径<br /><br /><br />3  python版本的对应<br />  view->tool  <br />  在工具栏中找到这个类似扳手加齿轮的图标<br />  如何在pycharm中切换python版本显示工具栏<br />  找到左侧 project interpreter选项<br /><br /><br />4  修改程序。需要重启odoo..如果进程有多个python-oe.exe 去取消了<br /><br />--------------------------------------------------<br /><br /><br /><br /><br />http://shine-it.net/index.php/topic,14848.msg25762.html#msg25762<br />« 于: 十二月 10, 2013, 03:23:21 下午 »<br />使用Pycharm开发调试OpenERP(服务端Python和客户端Javascript 联合调试)----这里是文字,完整在附件<br />  个人认为Pycharm是最好的Python开发工具,配置简单,操作简便,界面清爽,支持远程调试python,javascript调试,集成JDango等web框架,跨平台。功能非常强大。鉴于社区主要推荐的是Eclipse IDE,Eclipse本身是很好,万金油IDE,通过Pydev插件支持Python也不错,另外也有针对OpenERP的模版发布,利于快速开发模块。但对Python初学者来说配置工作比较多,Python本身要安装各种插件,即使以前用eclipse开发过java的人,同样不利于快速上手,因此,向python、或OpenERP初学者推荐Pycharm。<br />  本文分三个部分:1、安装开发环境:Python,Pycharm,OpenERP的Python依赖包。2、配置Pycharm,调试OpenERP服务端Python代码。3、调试OpenERP客户端Javascript代码。<br />一、  安装开发环境:<br />1、  下载安装必须软件:<br />  对Python不熟悉的同学,建议安装Python(x,y),600兆,这个第三方发布的Python包集成了很多Python常用社区模块。OpenERP需要十几个Python社区模块。<br />  下载Pycharm,下载专业版,专业版支持javascript调试,试用期过后,其实还是可以使用的。Pycharm是需要jre支持的,如果没有,则需要安装jre。<br />  下载OpenERP代码,解压到硬盘中,注意路径中不能有中文名文件夹。<br />  下载OpenERP数据库,Postgres。安装时,记下数据库管理员用户名和密码。<br />2、  配置Pycharm和OpenERP:<br />  打开Pycharm,导入OpenERP工程:<br /> <br />  选择下载的OpenERP代码目录:<br /> <br />这就完成了OpenERP工程的导入。<br />展开工程文件,从doc目录下拷贝 conf文件到根目录下:<br /> <br />点击根目录下的conf文件,进行配置:<br /> <br />注意db_user 和db_password是前面安装postgreSQL时的数据库用户名和密码。配置好后,选择工程根目录下的”opener-server”文件,右键点击,弹开菜单,Run。<br /> <br />  此时,运行结果,会报很多错误,关注最下面的错误,这些错误大多是模块未安装的错误,并提示缺少什么模块,OpenERP需要的模块列表在工程下目录openerp.egg-info内的文件requires.txt里,如下图:<br /> <br />  Python(x,y)已经有了很多插件,剩下大致有如下几个: <br />  这些是Python插件包在window下使用的安装包,下载地址在:http://www.lfd.uci.edu/~gohlke/pythonlibs 。逐个下载安装。<br />  全部安装完后,如还缺少,根据报错信息,找到确认模块名,打开cmd命令行窗口,运行 “pip install 模块名” 安装,模块名有时候与requires.txt文件里的不完全一致,需要到pip官网查询确认https://pypi.python.org/pypi 。<br />  如还是解决不了,到论坛或群里发帖吧。<br />二、  调试OpenERP服务端python代码:<br />      调试Python服务端代码,只需要在前面运行那里,选择debug即可,注意不要同时开启run和debug,OpenERP是一份代码允许同时运行多个实例的,因此不会提示是否以运行。如下图,只有一个debug窗口。多个运行就会有多个窗口。<br />    <br />      服务端代码调试,打开openerp-server文件,打上断点,即可跟踪OpenERP的启动过程:<br /> <br />      服务启动流程大致如下:<br /> <br />  <br />  模块启动完成后,OpenERP服务会开始监听8069端口的http请求,此时代码运行起始在services目录下,wsgi.py文件内,如下断点。即可跟踪对请求的一系列处理。<br /> <br />  请求处理流程大致如下:<br /> <br />  代码多跟踪几遍,就能掌握。<br />三、  调试OpenERP客户端javascript代码:<br />  在Pycharm里选择配置:<br /> <br />在弹出窗口内,点击 + 号,添加Javascript Debug配置:<br /> <br />  按如下配置,注意URL中的写法http://127.0.0.1:8069/?debug= 。<br />Debug参数让OpenERP服务输出的是原始js文件。<br /> <br />  保存返回主界面,如果此时OpenERP还没启动服务,则先运行operp-server,随便是run或debug。 然后再选择js debug,点击debug按钮:<br /> <br />  此时pycharm 会提示你安装 chrome插件,点击安装。安装完毕后,关掉chrome,再次点击debug运行,此时chrome就会连接上pycharm<br /> <br />  注意,此时Pycharm开启了两个调试进程,分别是python和javascript:<br /> <br />  可以联调js和python了。<br />  选择js debug下的 Scripts  tab栏,点击展开http://127.0.0.1:8069目录,选择需要调试的js文件。<br /> <br />比如选择web/static/src/js 目录下的boot.js文件,这个是OpenERP客户端javascript框架的启动文件,断点打在init方法内:<br /> <br />在chrome内登录后,会跳到这个断点,注意调试堆栈和 变量窗口:<br /> <br /><br />如果此时Python代码的运行也是debug模式的话,那么就能够实现客户端和服务端联合调试了。<br />      <br />    希望此文能给OpenERP初学者一些帮助。<br />* 使用Pycharm开发调试OpenERP.pdf (821.69 kB - 已被下载 1038 次.)


登录后回复
 

与 Odoo 中文社区 的连接断开,我们正在尝试重连,请耐心等待