使用WSL(Windows Subsystem for Linux)开发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作为开发环境,参考文档
  2. 使用Pycharm打卡项目文件夹,如下图:
  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作为终端,如下图:
  5. 修改项目的Inerpreter,如下图:
  6. 修改Pycharm的 “Run/Debug Configurations”,如下图:
  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. 项目文件夹如下图

  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”,如下图:

转载于:https://my.oschina.net/u/138005/blog/896319

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值