iT邦幫忙

2023 iThome 鐵人賽

DAY 2
0
Odoo

死嗑Odoo part II系列 第 2

Day 2 M1 Arm架構 導入Odoo環境

  • 分享至 

  • xImage
  •  

首先我個人使用的設備是MacBook Air M1

今天就來導入安裝環境吧,以下按照實際步驟來吧!

1.安裝系統所需套件
使用 Homebrew 安装 Python 3:

brew install python@3
  • PostgreSQL資料庫
    brew install postgresql
  • pip(Python套件管理器)
  • virtualenv(可選,用於建立虛擬環境境)
    pip3 install virtualenv

2.Clone Odoo 原始碼,使用以下命令从官方 GitHub 中Clone Odoo 原始碼並進入目錄:

git clone https://github.com/odoo/odoo.git
cd odoo
  1. 在Clone下來的Odoo目錄建立 Python 虛擬環境:
    使用 Python 3 ,此環境允许您在其中安装 Odoo 和其套件,不會與全局環境衝突:
python3 -m venv odoo_env

4.啟動虛擬環境:
於虛擬環境所在的目錄啟動虛擬環境:

source odoo_env/bin/activate

5.安裝套件:
在啟動的虛擬環境中,安装 Odoo 所需的套件。可以使用以下命令,
此動作將依照requirements.txt官方的文件安裝套件:

pip install -r requirements.txt

6.建立一个新的config文件,比如 odoo.conf,並使用vim開啟:

touch odoo.conf
vim odoo.conf

7.在config文件中新增以下内容(依照個人需求定義):

[options]
; 設定 Odoo 使用的DB連接數據
db_host = localhost
db_port = 5432
db_user = your_db_user
db_password = your_db_password
db_name = your_db_name

; 指定 Odoo 使用的port号
http_port = 8069

; 设置 Odoo 的模組路徑(依照個人安裝的odoo路徑設置)
addons_path = /path/to/your/addons_folder,/path/to/another/addons_folder

; 請用開發者模式(可選)
dev_mode = True

; 配置 Odoo log
logfile = /var/log/odoo/odoo.log

8.啟動 Odoo 服務,透過 -c 参数指定config文件路徑,
我是在odoo文件夾下創建odoo.conf直接於/odoo內執行:
./odoo-bin -c /odoo.conf
https://ithelp.ithome.com.tw/upload/images/20230917/201624845SbbAUdYKt.png

Oh-YA 啟動成功但...........................

https://ithelp.ithome.com.tw/upload/images/20230917/20162484Qta6lCCK3Q.png

Odoo web使用的port號為 8069
http://localhost:8069/
進入此路徑提示500Error,應該是db設置問題.............

server log 提示一堆錯誤跟警告,以下文長,今天先到此為止

2023-09-17 02:09:16,780 29480 ERROR ? odoo.modules.loading: Database odoo not initialized, you can force it with `-i base` 
2023-09-17 02:09:16,785 29480 INFO ? odoo.modules.registry: Registry loaded in 0.065s 
2023-09-17 02:09:16,788 29480 ERROR odoo odoo.http: Exception during request handling. 
Traceback (most recent call last):
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1584, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/service/model.py", line 133, in retrying
    result = func()
             ^^^^^^
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1596, in _serve_ir_http
    ir_http = self.registry['ir.http']
              ~~~~~~~~~~~~~^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/modules/registry.py", line 190, in __getitem__
    return self.models[model_name]
           ~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'ir.http'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1998, in __call__
    response = request._serve_db()
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1588, in _serve_db
    exc.error_response = self.registry['ir.http']._handle_error(exc)
                         ~~~~~~~~~~~~~^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/modules/registry.py", line 190, in __getitem__
    return self.models[model_name]
           ~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'ir.http'
2023-09-17 02:09:16,801 29480 INFO odoo werkzeug: 127.0.0.1 - - [17/Sep/2023 02:09:16] "GET / HTTP/1.1" 500 - 8 0.171 0.219
2023-09-17 02:09:17,018 29480 ERROR odoo odoo.http: Exception during request handling. 
Traceback (most recent call last):
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1584, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/service/model.py", line 133, in retrying
    result = func()
             ^^^^^^
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1596, in _serve_ir_http
    ir_http = self.registry['ir.http']
              ~~~~~~~~~~~~~^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/modules/registry.py", line 190, in __getitem__
    return self.models[model_name]
           ~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'ir.http'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1998, in __call__
    response = request._serve_db()
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1588, in _serve_db
    exc.error_response = self.registry['ir.http']._handle_error(exc)
                         ~~~~~~~~~~~~~^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/modules/registry.py", line 190, in __getitem__
    return self.models[model_name]
           ~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'ir.http'
2023-09-17 02:09:17,020 29480 INFO odoo werkzeug: 127.0.0.1 - - [17/Sep/2023 02:09:17] "GET /favicon.ico HTTP/1.1" 500 - 2 0.006 0.030
2023-09-17 02:09:18,966 29480 ERROR odoo odoo.sql_db: bad query: 
            SELECT latest_version
            FROM ir_module_module
             WHERE name='base'
        
ERROR: relation "ir_module_module" does not exist
LINE 3:             FROM ir_module_module
                         ^
 
2023-09-17 02:09:18,968 29480 WARNING odoo odoo.addons.base.models.ir_cron: Tried to poll an undefined table on database odoo. 
2023-09-17 02:10:07,867 29480 ERROR odoo odoo.sql_db: bad query: 
            SELECT latest_version
            FROM ir_module_module
             WHERE name='base'
        
ERROR: relation "ir_module_module" does not exist
LINE 3:             FROM ir_module_module
                         ^
 
2023-09-17 02:10:07,868 29480 WARNING odoo odoo.addons.base.models.ir_cron: Tried to poll an undefined table on database odoo. 
2023-09-17 02:10:20,006 29480 ERROR odoo odoo.sql_db: bad query: 
            SELECT latest_version
            FROM ir_module_module
             WHERE name='base'
        
ERROR: relation "ir_module_module" does not exist
LINE 3:             FROM ir_module_module
                         ^
 
2023-09-17 02:10:20,006 29480 WARNING odoo odoo.addons.base.models.ir_cron: Tried to poll an undefined table on database odoo. 
2023-09-17 02:10:27,830 29480 ERROR odoo odoo.http: Exception during request handling. 
Traceback (most recent call last):
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1584, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/service/model.py", line 133, in retrying
    result = func()
             ^^^^^^
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1596, in _serve_ir_http
    ir_http = self.registry['ir.http']
              ~~~~~~~~~~~~~^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/modules/registry.py", line 190, in __getitem__
    return self.models[model_name]
           ~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'ir.http'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1998, in __call__
    response = request._serve_db()
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1588, in _serve_db
    exc.error_response = self.registry['ir.http']._handle_error(exc)
                         ~~~~~~~~~~~~~^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/modules/registry.py", line 190, in __getitem__
    return self.models[model_name]
           ~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'ir.http'
2023-09-17 02:10:27,833 29480 INFO odoo werkzeug: 127.0.0.1 - - [17/Sep/2023 02:10:27] "GET / HTTP/1.1" 500 - 2 0.009 0.077
2023-09-17 02:10:27,945 29480 ERROR odoo odoo.http: Exception during request handling. 
Traceback (most recent call last):
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1584, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/service/model.py", line 133, in retrying
    result = func()
             ^^^^^^
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1596, in _serve_ir_http
    ir_http = self.registry['ir.http']
              ~~~~~~~~~~~~~^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/modules/registry.py", line 190, in __getitem__
    return self.models[model_name]
           ~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'ir.http'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1998, in __call__
    response = request._serve_db()
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/http.py", line 1588, in _serve_db
    exc.error_response = self.registry['ir.http']._handle_error(exc)
                         ~~~~~~~~~~~~~^^^^^^^^^^^
  File "/Users/zhuzhu/odoo/odoo/modules/registry.py", line 190, in __getitem__
    return self.models[model_name]
           ~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'ir.http'
2023-09-17 02:10:27,948 29480 INFO odoo werkzeug: 127.0.0.1 - - [17/Sep/2023 02:10:27] "GET /favicon.ico HTTP/1.1" 500 - 2 0.006 0.018
2023-09-17 02:11:07,875 29480 ERROR odoo odoo.sql_db: bad query: 
            SELECT latest_version
            FROM ir_module_module
             WHERE name='base'
        
ERROR: relation "ir_module_module" does not exist
LINE 3:             FROM ir_module_module
                         ^
 
2023-09-17 02:11:07,877 29480 WARNING odoo odoo.addons.base.models.ir_cron: Tried to poll an undefined table on database odoo. 
2023-09-17 02:11:21,025 29480 ERROR odoo odoo.sql_db: bad query: 
            SELECT latest_version
            FROM ir_module_module
             WHERE name='base'
        
ERROR: relation "ir_module_module" does not exist
LINE 3:             FROM ir_module_module
                         ^
 
2023-09-17 02:11:21,025 29480 WARNING odoo odoo.addons.base.models.ir_cron: Tried to poll an undefined table on database odoo. 
2023-09-17 02:12:07,885 29480 ERROR odoo odoo.sql_db: bad query: 
            SELECT latest_version
            FROM ir_module_module
             WHERE name='base'
        
ERROR: relation "ir_module_module" does not exist
LINE 3:             FROM ir_module_module
                         ^
 
2023-09-17 02:12:07,887 29480 WARNING odoo odoo.addons.base.models.ir_cron: Tried to poll an undefined table on database odoo.

上一篇
Day 1 初次參賽。。。。的前言
下一篇
Day 3 環境設定 Part II
系列文
死嗑Odoo part II5
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

0
arguskao
iT邦新手 3 級 ‧ 2023-09-17 10:55:11

之後會考慮用Docker嗎?

ga035756 iT邦新手 5 級 ‧ 2023-09-17 19:05:59 檢舉

順利完成後會唷~
但得先解決現行問題

我要留言

立即登入留言