05.odoo12开源框架学习
Posted ericchengge677
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了05.odoo12开源框架学习相关的知识,希望对你有一定的参考价值。
博客为日常工作学习积累总结:
1.odoo12学习
参考博客:https://alanhou.org/centos-odoo-12/
CentOS 7快速安装配置 Odoo 12
添加新用户必做,不然文件权限odoo用户五权限
useradd -m -U -r -d /opt/odoo -s /bin/bash odoo
设置密码: passwd odoo
不设置执行后述操作时会报出xxx is not in the sudoers file. This incident will be reported.
su - root
visudo
# 在root ALL=(ALL) ALL下添加相应用户
odoo ALL=(ALL) ALL
进入odoo用户:su - odoo
sudo yum -y update
sudo yum -y install epel-release
这一步我用的是我现有的python环境略过了博客上的按照方法
start
# 添加Software Collections (SCL) 安装 Python
sudo yum -y install centos-release-scl
sudo yum -y install rh-python36
# 或直接执行(可能需要提前执行yum -y groupinstall "Development tools")
sudo yum -y install python36 python36-devel
# 又或者
curl -O https://www.python.org/ftp/python/3.6.7/Python-3.6.7rc2.tgz
tar xf Python-3.6.7rc2.tgz
cd Python-3.6.7rc2
./configure
make
sudo make install
# 安装其它所需依赖
end
sudo yum -y install git gcc wget nodejs-less libxslt-devel bzip2-devel openldap-devel libjpeg-devel freetype-devel
补充:更新国内 yum 源
sudo yum install wget -y
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sudo yum makecache
安装和配置 PostgreSQL
sudo yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
sudo yum install postgresql10 postgresql10-server -y
# 初始化
sudo /usr/pgsql-10/bin/postgresql-10-setup initdb
# 启动服务
sudo systemctl enable postgresql-10
sudo systemctl start postgresql-10
# 创建用户(可任选名称,与前面创建的系统用户名需相同)
sudo su - postgres -c "createuser -s odoo"
ALTER USER odoo WITH PASSWORD ‘123456‘
配置远程访问数据库
修改postgres数据库管理员密码:
su - postgres 切换用户,执行后提示符会变为 ‘-bash-4.2$’,切换为UNIX风格的bash
psql -U postgres 登录数据库,执行后提示符变为 ‘postgres=#’
ALTER USER postgres WITH PASSWORD ‘123456’ 设置postgres用户密码
\q 退出数据库
切换到root配置一下远程连接。
开启远程访问
vi /var/lib/pgsql/10/data/postgresql.conf
修改
#listen_addresses = ‘localhost’
为
listen_addresses=’ *’
当然,此处‘ *’也可以改为任何你想开放的服务器IP
信任远程连接
vi /var/lib/pgsql/10/data/pg_hba.conf
修改如下内容,信任指定服务器连接
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 0.0.0.0/0 trust
host all all 192.168.1.2/32 trust
我的系统已经关闭防火墙:略过
start
远程连接配置完成,由于系统原因,还需要在防火墙中打开相应的端口。
打开防火墙
CentOS 防火墙中内置了PostgreSQL服务,配置文件位置在 ,我们只需以服务方式将PostgreSQL服务开放即可。
sudo firewall-cmd --permanent --zone=public --add-port=5432/tcp
sudo firewall-cmd --reload
查看配置文件地址
查看当前配置文件地址,修改配置文件,是该用户可以通过远程(navicate)连接数据库
查看配置文件路径
select name,setting from pg_settings where category=‘File Locations‘;
end
systemctl restart postgresql-10.service
安装Wkhtmltopdf
wget https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox-0.12.5-1.centos7.x86_64.rpm
sudo yum localinstall wkhtmltox-0.12.5-1.centos7.x86_64.rpm -y
# 中文字体
sudo yum install -y wqy*
安装Sass
sudo yum install -y sassc
安装 Odoo
安装及配置
# 切换用户
sudo su - odoo
cd /opt/odoo
wget http://nightly.odoo.com/12.0/nightly/src/odoo_12.0.latest.tar.gz
# 或git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 /opt/odoo/odoo12 (我使用git拉取代码)
tar -zxvf odoo_12.0.latest.tar.gz
mv odoo-12.0.post20181019/ odoo12
我的Python环境这一步不需要做
# 当前使用 nightly 版本有一个坑,需要自行添加 odoo-bin 文件
#!/usr/bin/env python3
# set server timezone in UTC before time module imported
__import__(‘os‘).environ[‘TZ‘] = ‘UTC‘
import odoo
if __name__ == "__main__":
odoo.cli.main()
#添加执行权限 由于我的环境按照jdk python是用的root权限因此odoo会没有权限访问python3
chmod +x odoo12/odoo-bin
chown -R odoo:odoo /opt
chown -R odoo:odoo /application
#环境搭建
python -m venv odoo12-venv
source odoo12-venv/bin/activate
# 或者 Virtualenvwrapper(使用这种方法/etc/systemd/system/odoo12.service也需调整)
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python36 get-pip.py
pip3 install virtualenvwrapper
# vi ~/.bashrc
export WORKON_HOME=/opt/virtualenvs
# export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python36
source /usr/bin/virtualenvwrapper.sh
#重载.bashrc
source ~/.bashrc
# 安装依赖包
pip3 install -i https://pypi.douban.com/simple -r odoo12/requirements.txt
deactivate
# 创建自定义插件目录,如果使用 Git 建议将 local-addons 放在与 odoo12同一级
mkdir odoo12/local-addons
# 创建配置文件(<a href="https://www.jianshu.com/p/abf366d7319e" target="_blank" rel="noopener" data-mce-href="https://www.jianshu.com/p/abf366d7319e">配置项详解参考</a>)
# odoo12/odoo-bin --help也可进行查看
sudo vi /etc/odoo12.conf
[options]
; This is the password that allows database operations:
# 此处密码请自行修改
admin_passwd = superadmin_passwd
db_host = False
db_port = False
db_user = odoo
db_password = False
; addons_path = /opt/odoo/odoo12/odoo/addons
; If you are using custom modules
addons_path = /opt/odoo/odoo12/addons,/opt/odoo/odoo12/local-addons
# 切换用户
sudo su - odoo
cd /opt/odoo
wget http://nightly.odoo.com/12.0/nightly/src/odoo_12.0.latest.tar.gz
# 或git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 /opt/odoo/odoo12
tar -zxvf odoo_12.0.latest.tar.gz
mv odoo-12.0.post20181019/ odoo12
# 当前使用 nightly 版本有一个坑,需要自行添加 odoo-bin 文件
#!/usr/bin/env python3
# set server timezone in UTC before time module imported
__import__(‘os‘).environ[‘TZ‘] = ‘UTC‘
import odoo
if __name__ == "__main__":
odoo.cli.main()
#添加执行权限
chmod +x odoo12/odoo-bin
#环境搭建
python36 -m venv odoo12-venv
source odoo12-venv/bin/activate
# 或者 Virtualenvwrapper(使用这种方法/etc/systemd/system/odoo12.service也需调整)
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python36 get-pip.py
pip3 install virtualenvwrapper
# vi ~/.bashrc
export WORKON_HOME=/opt/virtualenvs
# export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python36
source /usr/bin/virtualenvwrapper.sh
#重载.bashrc
source ~/.bashrc
# 安装依赖包
pip3 install -i https://pypi.douban.com/simple -r odoo12/requirements.txt
deactivate
# 创建自定义插件目录,如果使用 Git 建议将 local-addons 放在与 odoo12同一级
mkdir odoo12/local-addons
# 创建配置文件(<a href="https://www.jianshu.com/p/abf366d7319e" target="_blank" rel="noopener" data-mce-href="https://www.jianshu.com/p/abf366d7319e">配置项详解参考</a>)
# odoo12/odoo-bin --help也可进行查看
sudo vi /etc/odoo12.conf
[options]
; This is the password that allows database operations:
# 此处密码请自行修改
admin_passwd = superadmin_passwd
db_host = False
db_port = False
db_user = odoo
db_password = False
; addons_path = /opt/odoo/odoo12/odoo/addons
; If you are using custom modules
addons_path = /opt/odoo/odoo12/odoo/addons,/opt/odoo/odoo12/local-addons
添加服务
sudo vi /etc/systemd/system/odoo12.service
[Unit]
Description=Odoo12
Requires=postgresql-10.service
After=network.target postgresql-10.service
[Service]
Type=simple
SyslogIdentifier=odoo12
PermissionsStartOnly=true
User=odoo
Group=odoo
WorkingDirectory=/opt/odoo
Environment=/opt/odoo/odoo12-venv/bin/activate
ExecStart=/opt/odoo/odoo12-venv/bin/python3 /opt/odoo/odoo12/odoo-bin -c /etc/odoo12.conf
# ExecStart=/usr/bin/scl enable rh-python36 -- /opt/odoo/odoo12-venv/bin/python3 /opt/odoo/odoo12/odoo-bin -c /etc/odoo12.conf
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target
# 启动服务
sudo systemctl daemon-reload
sudo systemctl start odoo12
sudo systemctl enable odoo12
sudo vi /etc/systemd/system/odoo12.service
[Unit]
Description=Odoo12
Requires=postgresql-10.service
After=network.target postgresql-10.service
[Service]
Type=simple
SyslogIdentifier=odoo12
PermissionsStartOnly=true
User=odoo
Group=odoo
WorkingDirectory=/opt/odoo
Environment=/opt/odoo/odoo12-venv/bin/activate
ExecStart=/opt/odoo/odoo12-venv/bin/python3 /opt/odoo/odoo12/odoo-bin -c /etc/odoo12.conf
# ExecStart=/usr/bin/scl enable rh-python36 -- /opt/odoo/odoo12-venv/bin/python /opt/odoo/odoo12/odoo-bin -c /etc/odoo12.conf
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target
# 启动服务
sudo systemctl daemon-reload
sudo systemctl start odoo12
示例配置文件
[options]
addons_path = /usr/lib/python3/dist-packages/odoo/addons
admin_passwd = $pbkdf2-sha512$25000$y9k7Z4zROifEOOf8v5fSeg$WD0vlcapmdkyCY8Uy9Md/Z1kchm8Sj942E4B1Ry13iwcCKaRFf1t3DEPYQrsB6iPwb2K/kJ6obs9CX2HRsx9KA
csv_internal_sep = ,
data_dir = /var/lib/odoo/.local/share/Odoo
db_host = False
db_maxconn = 64
db_name = False
db_password = False
db_port = False
db_sslmode = prefer
db_template = template0
db_user = odoo
dbfilter =
demo = {}
email_from = False
geoip_database = /usr/share/GeoIP/GeoLite2-City.mmdb
http_enable = True
http_interface =
http_port = 8069
import_partial =
limit_memory_hard = 2684354560
limit_memory_soft = 2147483648
limit_request = 8192
limit_time_cpu = 60
limit_time_real = 120
limit_time_real_cron = -1
list_db = True
log_db = False
log_db_level = warning
log_handler = :INFO
log_level = info
logfile = /var/log/odoo/odoo-server.log
logrotate = False
longpolling_port = 8072
max_cron_threads = 2
osv_memory_age_limit = 1.0
osv_memory_count_limit = False
pg_path = None
pidfile = None
proxy_mode = False
reportgz = False
server_wide_modules = base,web
smtp_password = False
smtp_port = 25
smtp_server = localhost
smtp_ssl = False
smtp_user = False
syslog = False
test_enable = False
test_file = False
test_tags = None
translate_modules = [‘all‘]
unaccent = False
without_demo = False
workers = 0
[options]
addons_path = /usr/lib/python3/dist-packages/odoo/addons
admin_passwd = $pbkdf2-sha512$25000$y9k7Z4zROifEOOf8v5fSeg$WD0vlcapmdkyCY8Uy9Md/Z1kchm8Sj942E4B1Ry13iwcCKaRFf1t3DEPYQrsB6iPwb2K/kJ6obs9CX2HRsx9KA
csv_internal_sep = ,
data_dir = /var/lib/odoo/.local/share/Odoo
db_host = False
db_maxconn = 64
db_name = False
db_password = False
db_port = False
db_sslmode = prefer
db_template = template0
db_user = odoo
dbfilter =
demo = {}
email_from = False
geoip_database = /usr/share/GeoIP/GeoLite2-City.mmdb
http_enable = True
http_interface =
http_port = 8069
import_partial =
limit_memory_hard = 2684354560
limit_memory_soft = 2147483648
limit_request = 8192
limit_time_cpu = 60
limit_time_real = 120
limit_time_real_cron = -1
list_db = True
log_db = False
log_db_level = warning
log_handler = :INFO
log_level = info
logfile = /var/log/odoo/odoo-server.log
logrotate = False
longpolling_port = 8072
max_cron_threads = 2
osv_memory_age_limit = 1.0
osv_memory_count_limit = False
pg_path = None
pidfile = None
proxy_mode = False
reportgz = False
server_wide_modules = base,web
smtp_password = False
smtp_port = 25
smtp_server = localhost
smtp_ssl = False
smtp_user = False
syslog = False
test_enable = False
test_file = False
test_tags = None
translate_modules = [‘all‘]
unaccent = False
without_demo = False
workers = 0
2.整合邮箱:
[email protected]
mail.fromname=system messenger
mail.host=smtp.honortone.com
mail.password=be587446
mail.smtp.auth=true
mail.smtp.timeout=25000
[email protected]
smtp_password = be587446
smtp_port = 25
smtp_server = smtp.honortone.com
smtp_ssl = False
smtp_user = [email protected]
email_from = [email protected]
3..整合微信:可参考代码发布,哈哈
mkdir /opt/odoo/odoo12/local-addons/oejia_wx
git clone https://www.github.com/JoneXiong/oejia_wx/ --depth 1 --branch 12.0 /opt/odoo/odoo12/local-addons/oejia_wx
4..整合国外的muk_web:可参考代码发布,哈哈
mkdir /opt/odoo/odoo12/local-addons/muk_web
git clone https://github.com/muk-it/muk_web --depth 1 --branch 12.0 /opt/odoo/odoo12/local-addons/muk_web
5.整合国外的auto_backup自动备份:可参考代码发布,哈哈
mkdir /opt/odoo/odoo12/local-addons/auto_backup
git clone https://github.com/Yenthe666/auto_backup --depth 1 --branch 12.0 /opt/odoo/odoo12/local-addons/auto_backup
pip3 install -i https://pypi.douban.com/simple -r odoo12/local-addons/auto_backup/requirements.txt
6.整合国外的addons-onestein
可参考代码发布,哈哈
mkdir /opt/odoo/odoo12/local-addons/addons-onestein
git clone https://github.com/aliensoftwaredev/Odoo --depth 1 --branch 12.0 /opt/odoo/odoo12/local-addons/addons-onestein
7.整合国外的aliensoftwaredev:可参考代码发布,哈哈
mkdir /opt/odoo/odoo12/local-addons/aliensoftwaredev
git clone https://github.com/aliensoftwaredev/Odoo --depth 1 --branch 12.0 /opt/odoo/odoo12/local-addons/aliensoftwaredev
8.整合国内的oejia_weshop:可参考代码发布,哈哈
mkdir /opt/odoo/odoo12/local-addons/oejia_weshop
git clone https://github.com/JoneXiong/oejia_weshop --depth 1 --branch 12.0 /opt/odoo/odoo12/local-addons/oejia_weshop
pip3 install -i https://pypi.douban.com/simple -r /opt/odoo/odoo12/local-addons/oejia_weshop/requirements.txt
9.整合国内的oejia_menu:可参考代码发布,哈哈
mkdir /opt/odoo/odoo12/local-addons/oejia_menu
git clone https://github.com/JoneXiong/oejia_menu --depth 1 --branch 12.0 /opt/odoo/odoo12/local-addons/oejia_menu
10.整合国内的oejia_weshop:可参考代码发布,哈哈
mkdir /opt/odoo/odoo12/local-addons/weodoo
git clone https://github.com/JoneXiong/weodoo --depth 1 --branch master /opt/odoo/odoo12/local-addons/weodoo
https://github.com/OmniaGit/odooplm
10.整合国内的odooplm:可参考代码发布,哈哈
mkdir /opt/odoo/odoo12/local-addons/odooplm
git clone https://github.com/OmniaGit/odooplm --depth 1 --branch 12.0 /opt/odoo/odoo12/local-addons/odooplm
7.整合国外的theme_nice_bootstrap-12.0.1.0.zip
unzip theme_nice_bootstrap-12.0.1.0.zip
8.整合国外的asset_documents-12.0.1.0.0.zip
unzip asset_documents-12.0.1.0.0.zip
9.整合国外的backend_theme_v12-12.0.0.1.zip
unzip backend_theme_v12-12.0.0.1.zip
以上是关于05.odoo12开源框架学习的主要内容,如果未能解决你的问题,请参考以下文章