Odoo Command及VSCode 開發設置

2023-02-01
Windows環境下,使用Odoo安裝包安裝Odoo服務的指令使用方法:
  • Pythod指令: py (如果沒有安裝python可直接指向Odoo的安裝路徑 如: D:\Program Files\Odoo 15.0.20220711\python\python.exe) 
    注意: 如果是使用本機安裝的python來執行Odoo可能會遇到很多問題,最保險的方式是直接用安裝包中的python路徑
  • Odoo-bin的位置: "D:Program FilesOdoo 15.0.20220711serverodoo-bin"

更新模塊指令 
  • python指令: py (如果沒有安裝pythod可直接指向Odoo的安裝路徑 如: D:\Program Files\Odoo 15.0.20220711\python\python.exe)
  • Odoo-bin的位置: "D:Program FilesOdoo 15.0.20220711serverodoo-bin"
  • -u: 更新命令
  • "website": 模塊名稱
py "D:Program FilesOdoo 15.0.20220711serverodoo-bin" -u "website"

如果要使用VSCode來Debug,請先至Task manager中的services清單中停止系統預設的Odoo服務
alt text

然後再Odoo目錄下建立.vscode/launch.json檔案,設定如下: 
  • python: Window下Odoo安裝路徑下的python.exe
  • program: Window下Odoo安裝路徑下odoo-bin的位置
  • args: [ "-c", "Window下Odoo安裝路徑下odoo.conf位置
{
    "version":"0.2.0",
    "configurations":[
        {
            "name":"odoo15",
            "type":"python",
            "request":"launch",
            "python":"D:\Program Files\Odoo 15.0.20220711\python\python.exe",
            "program":"D:\Program Files\Odoo 15.0.20220711\server\odoo-bin",
            "args":[
                "-c",
                "D:\Program Files\Odoo 15.0.20220711\server\odoo.conf"
            ]
        }
    ]
}

透過VSCode的Run>Start Debugging選單,執行Debug,或快捷鍵F5
alt text

VSCode執行Debug的畫面如下圖
alt text

Debug執行時,Terminal會停在執行狀態,若要執行Odoo-bin指令,需要額外再開一個Terminal來執行,而且執行完後需要手動透過Ctrl+C結束執行,挺麻煩的,但在Windows下這是可以運作的。
 

Contact

Github

Codepen

歡迎參觀我的賣場
© 2013 Copyright Digishot Web | Design Tools
Visitors【636814】
digishot webdesign studio