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 版本。

    ***** 新手犯了一个低级的错误,发现[b]Odoo在Windows下不能正常运行[/b]。  建议大家不要尝试了。 留这个帖子引以为戒。  **********

    原文在 [检测到链接无效,已移除]

    Debug Odoo using PyCharm in Windows
    08 Sep 2014
    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.

    I. Install packages and source code
    1. Get Odoo source code and change branch to 8.0
    git clone https://github.com/odoo/odoo.git br />git checkout 8.0
    2. Install Visual Studio if you don't have one.
    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:

    If you have Visual Studio 2013 installed (Visual Studio Version 12), execute SET VS90COMNTOOLS=%VS120COMNTOOLS%.

    For Visual Studio 2012 (Visual Studio Version 11), execute SET VS90COMNTOOLS=%VS110COMNTOOLS%.

    For Visual Studio 2010, execute SET VS90COMNTOOLS=%VS100COMNTOOLS%.

    3. Install required packages from a binary source
    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 />
    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.

    4. Create a virtual environment
    This is optional but it's a good idea to use a virtual environment.

    In PyCharm, open the odoo folder to create a new project.
    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.

    You should see some packages such as pip, psycopg2, python-ldap, pywin32 and setuptools. It is a good idea to upgrade pip and setuptools.
    Select pip, then the up-arrow icon on the right side to upgrade it. Do the same to upgrade setuptools.

    5. Copy and edit requirments.txt
    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

    pip -r requirements.txt
    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.

    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.

    However, you still need to install Postgresql and configure the Odoo to work with it.

    II. Install PostgreSQL and configure Odoo
    1. Download and install PostgreSQL for Windows.
    2. Create a new role with superuser privilege for Odoo application.
    In my case, I create a superuser "odoo" and set its password as "odoo".

    3. Check PostgreSQL configuration
    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.

    In postgresql.conf, make sure that listen_addresses are enabled. It is checked by default.

    In pg_hba.conf, enable the "host all all md5". It means localhost can be connected with a role name and password. It is checked by default.

    4. Config Odoo
    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:

    ; This is the password that allows database operations:
    ; admin_passwd = admin
    db_host = localhost
    db_port = 5432
    db_user = odoo
    db_password = odoo
    addons_path = D:\Dev\PyCharmProjects\odoo\addons
    In the addons_path option, set it to the addons directory in your Odoo project root.

    Then in PyCharm menu Run --> Edit Configurations, click "+" on the top left to create a new configuration with the following settings:

    Name: Odoo8 Single instance checkbox: checked Script: D:\Dev\PyCharmProjects\odoo\openerp-server Script parameters: --config=D:\Dev\odooTest\openerp-server.conf

    Congratulations, you should be able to run and debug Odoo !!!

    III. Issues and solutions
    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.

    Packages such as lxml, psycopg2, python-ldap had many compile errors. The solution is downloading and installing binary packages from [检测到链接无效,已移除] br />
    The Pillow package did work correctly because of an error of 'decoder zip not available'. Again, installing binary package fixed it.

    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的路径接

    Pycharm 联合调试OpenERP服务端和客户端

    1.绿色版如果用来开发。不要安装服务,就是不要点击service_install ,否则停止python-oe.exe也会马上自动运行了

    2. 把openerp-server.conf 复制到source,并修改 openerp-server.conf中的addons路径

    3  python版本的对应
      找到左侧 project interpreter选项

    4  修改程序。需要重启odoo..如果进程有多个python-oe.exe 去取消了


    <br / [检测到链接无效,已移除] br />« 于: 十二月 10, 2013, 03:23:21 下午 »
    使用Pycharm开发调试OpenERP(服务端Python和客户端Javascript 联合调试)----这里是文字,完整在附件
      个人认为Pycharm是最好的Python开发工具,配置简单,操作简便,界面清爽,支持远程调试python,javascript调试,集成JDango等web框架,跨平台。功能非常强大。鉴于社区主要推荐的是Eclipse IDE,Eclipse本身是很好,万金油IDE,通过Pydev插件支持Python也不错,另外也有针对OpenERP的模版发布,利于快速开发模块。但对Python初学者来说配置工作比较多,Python本身要安装各种插件,即使以前用eclipse开发过java的人,同样不利于快速上手,因此,向python、或OpenERP初学者推荐Pycharm。
    一、  安装开发环境:
    1、  下载安装必须软件:
    2、  配置Pycharm和OpenERP:


    展开工程文件,从doc目录下拷贝 conf文件到根目录下:


    注意db_user 和db_password是前面安装postgreSQL时的数据库用户名和密码。配置好后,选择工程根目录下的”opener-server”文件,右键点击,弹开菜单,Run。


      这些是Python插件包在window下使用的安装包,下载地址在:http://www.lfd.uci.edu/~gohlke/pythonlibs 。逐个下载安装。
      全部安装完后,如还缺少,根据报错信息,找到确认模块名,打开cmd命令行窗口,运行 “pip install 模块名” 安装,模块名有时候与requires.txt文件里的不完全一致,需要到pip官网查询确认https://pypi.python.org/pypi 。
    二、  调试OpenERP服务端python代码:




    三、  调试OpenERP客户端javascript代码:

    在弹出窗口内,点击 + 号,添加Javascript Debug配置:

      按如下配置,注意URL中的写法http:// 。

      保存返回主界面,如果此时OpenERP还没启动服务,则先运行operp-server,随便是run或debug。 然后再选择js debug,点击debug按钮:

      此时pycharm 会提示你安装 chrome插件,点击安装。安装完毕后,关掉chrome,再次点击debug运行,此时chrome就会连接上pycharm


      选择js debug下的 Scripts  tab栏,点击展开http://目录,选择需要调试的js文件。

    比如选择web/static/src/js 目录下的boot.js文件,这个是OpenERP客户端javascript框架的启动文件,断点打在init方法内:

    在chrome内登录后,会跳到这个断点,注意调试堆栈和 变量窗口:

    * 使用Pycharm开发调试OpenERP.pdf (821.69 kB - 已被下载 1038 次.)