如何使用WSL开发odoo

发布时间:2021-09-10 14:20:41 作者:小新
来源:亿速云 阅读:238

这篇文章给大家分享的是有关如何使用WSL开发odoo的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

在WSL安装ODOO

  1. 在 控制面板\所有控制面板项\程序和功能 启用或关闭Windows 功能中安装“适用于Linux的Windows子系统”。

  2. 在Microsoft Store安装“Debian GNU/Linux”

  3. 在cmd中输入bash就可以进入bash界面。等待一段时间后提示输入账号密码。此时关闭bash,再次打开cmd,执行以下命令,我们修改成默认root用户登陆

    debian config --default-user root


    这样在cmd输入bash就可以默认root用户登陆了 

  4. 查看Linux的版本

    cat /etc/issue
    Debian GNU/Linux 9 \n \l


     

  5. 修改国内源

    #复制原文件备份
    cp /etc/apt/sources.list /etc/apt/sources.list.bak
    
    #编辑源列表文件,注释原有的
    nano /etc/apt/sources.list
    
    #阿里云源
    deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
    deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
    deb http://mirrors.aliyun.com/debian-security stretch/updates main
    deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
    deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
    deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
    deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
    deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
    
    #更新
    apt-get update && apt-get upgrade


     

  6. 在windows中安装Postgresql,修改pg_hba.conf文件,添加0.0.0.0/0  

    # IPv4 local connections:
    host    all             all             127.0.0.1/32            md5
    host    all             all             0.0.0.0/0               md5


     

  7. 安装odoo

    apt-get install apt-transport-https ca-certificates
    wget -O - https://nightly.odoo.com/odoo.key | apt-key add -
    echo "deb http://nightly.odoo.com/12.0/nightly/deb/ ./" >> /etc/apt/sources.list.d/odoo.list
    apt-get update && apt-get install odoo -y
    ./odoo start
    
    #停止Odoo
    cd /etc/init.d
    ./odoo stop
    
    #启动Odoo
    cd /etc/init.d
    ./odoo start
    
    #重启Odoo
    cd /etc/init.d
    ./odoo restart


     

  8. 安装wkhtmltopdf

    curl -o wkhtmltox.tar.xz -SL https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
    echo '3f923f425d345940089e44c1466f6408b9619562 wkhtmltox.tar.xz' | sha1sum -c -
    tar xvf wkhtmltox.tar.xz
    cp wkhtmltox/lib/* /usr/local/lib/
    cp wkhtmltox/bin/* /usr/local/bin/
    cp -r wkhtmltox/share/man/man1 /usr/local/share/man/
    
    sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin
    sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin


     

  9. 修改odoo.conf文件

    [options]
    ; This is the password that allows database operations:
    ; admin_passwd = admin
    db_host = localhost
    db_port = False
    db_user = odoo
    db_password = odoo
    bin_path=/usr/bin/wkhtmltopdf
    addons_path = /mnt/g/git@osc/odoo/12.0/themes
    
    ;/mnt/g/git@osc/odoo/12.0/themes 是自己开发模块路径,保存在G盘


     

  10. 重新启动odoo

    cd /etc/init.d
    ./odoo restart


     

  11. 打开浏览器 http://localhost:8069,此时可以做demo服务器运行了。



配置Pycharm的WSL开发环境

  1. 配置Pycharm使用WSL作为开发环境,参考文档
    如何使用WSL开发odoo

  2. 使用Pycharm打卡项目文件夹,如下图:
    如何使用WSL开发odoo

  3. 复制odoo-bin和odoo.conf文件到项目文件根目录,修改odoo.conf

    [options]
    ; This is the password that allows database operations:
    ; admin_passwd = admin
    db_host = localhost
    db_port = False
    db_user = odoo
    db_password = odoo
    addons_path =/usr/lib/python3/dist-packages/odoo/addons,/mnt/g/odoo/12.0/eis,/mnt/g/odoo/12.0/rainbow/
    bin_path=/usr/bin/wkhtmltopdf


     

  4. 使用WSL作为终端,如下图:
    如何使用WSL开发odoo

  5. 修改项目的Inerpreter,如下图:
    如何使用WSL开发odoo

  6. 修改Pycharm的 “Run/Debug Configurations”,如下图:
    如何使用WSL开发odoo

  7. 至此,可以在Windows10下使用WSL环境进行愉快的开发了,更新Odoo的基础代码也方便,在WSL下,运行

    apt-get update -y

后记:发现在WSL中开发有性能的问题,重置了WSL,不在WSL中安装odoo,按如下操作:

  1. 更新和安装python

    #更新
    apt-get update && apt-get upgrade -y
    
    #安装Python3及其他
    apt-get install python3 python3-pip python3-dev -y
  2. 安装wkhtmltopdf

    curl -o wkhtmltox.tar.xz -SL https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
    echo '3f923f425d345940089e44c1466f6408b9619562 wkhtmltox.tar.xz' | sha1sum -c -
    tar xvf wkhtmltox.tar.xz
    cp wkhtmltox/lib/* /usr/local/lib/
    cp wkhtmltox/bin/* /usr/local/bin/
    cp -r wkhtmltox/share/man/man1 /usr/local/share/man/
    
    sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin
    sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin
  3. 在项目文件夹中git clone odoo12.0的最新代码

    git clone https://github.com/odoo/odoo.git --depth 1 --branch 12.0 --single-branch src
  4. 在WSL中切换到项目文件夹src目录下,安装requirements.txt依赖

    pip install -r requirements.txt -i https://pypi.doubanio.com/simple
  5. 项目文件夹如下图
    如何使用WSL开发odoo

  6. 复制odoo-bin和odoo.conf文件到项目文件根目录,修改odoo.conf

    [options]
    ; This is the password that allows database operations:
    ; admin_passwd = admin
    db_host = localhost
    db_port = False
    db_user = odoo
    db_password = odoo
    addons_path = eis,rainbow,src/addons,src/odoo/addons
    bin_path=/usr/bin/wkhtmltopdf
  7. 修改Pycharm的 “Run/Debug Configurations”,如下图:
    如何使用WSL开发odoo

感谢各位的阅读!关于“如何使用WSL开发odoo”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

推荐阅读:
  1. Odoo是怎么打败传统ERP的
  2. Odoo与ERP传统软件有什么不同?

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

wsl odoo

上一篇:使用css如何选择background-image和img标签

下一篇:怎么通过重启路由的方法切换IP地址

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》