Skip to content

Commit 14a653e

Browse files
committed
Update
1 parent c58680e commit 14a653e

File tree

2 files changed

+101
-8
lines changed

2 files changed

+101
-8
lines changed

technology/git/git-tools.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ if find . -type f -name "*.py" | grep -q "/."; then
7979

8080
# Check if "janitor" is in requirements.txt and replace it with pyjanitor
8181
if grep -q "janitor" "requirements.txt"; then
82-
sed -i '/janitor/c\pyjanitor==0.32.6' requirements.txt
82+
sed -i '/janitor/c\pyjanitor==0.32.7' requirements.txt
8383
pre-commit run --files "./requirements.txt"
8484
fi
8585

technology/odoo/odoo-installation-docker.md

Lines changed: 100 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Odoo Installation (Docker)
22

33
> [!NOTE]
4-
> Last update: 2025-12-29
4+
> Last update: 2025-12-30
55
66
```.sh
77
# Settings
@@ -37,6 +37,46 @@ sudo usermod -aG docker $system_user
3737
groups $system_user
3838
```
3939

40+
### OCA Submodules
41+
42+
```.sh
43+
# Initialize git repo in the root odoo folder
44+
cd $domain_root_path/domains/$subdomain.$domain/odoo
45+
git config --global --add safe.directory "$domain_root_path/domains/$subdomain.$domain/odoo"
46+
git init
47+
48+
# Create the addons directory
49+
mkdir -p "addons"
50+
cd "addons"
51+
52+
# Add OCA repositories as submodules
53+
git submodule add --branch $odoo_version https://github.com/OCA/brand.git oca/brand
54+
git submodule add --branch $odoo_version https://github.com/OCA/product-attribute.git oca/product-attribute
55+
git submodule add --branch $odoo_version https://github.com/OCA/queue.git oca/queue
56+
git submodule add --branch $odoo_version https://github.com/OCA/server-tools.git oca/server-tools
57+
# git submodule add --branch $odoo_version https://github.com/roboes/odoo-woocommerce-sync.git custom/odoo-woocommerce-sync
58+
59+
git commit -m "Add OCA submodules for Odoo $odoo_version"
60+
```
61+
62+
### Dockerfile & Docker Compose
63+
64+
```.sh
65+
# Create Dockerfile for custom Odoo image with Python dependencies
66+
cat <<'EOF' > "$domain_root_path/domains/$subdomain.$domain/odoo/Dockerfile"
67+
ARG ODOO_VERSION
68+
FROM odoo:${ODOO_VERSION}
69+
70+
USER root
71+
72+
# Mount addons folder during build to install requirements (requires BuildKit)
73+
RUN --mount=type=bind,target=/tmp/addons,source=addons \
74+
find /tmp/addons -name "requirements.txt" -exec pip3 install --no-cache-dir -r {} \; || true
75+
76+
USER odoo
77+
EOF
78+
```
79+
4080
```.sh
4181
# Create docker-compose.yml
4282
cat <<EOF > "$domain_root_path/domains/$subdomain.$domain/odoo/docker-compose.yml"
@@ -45,7 +85,10 @@ name: odoo
4585
services:
4686
odoo:
4787
container_name: "odoo_server_${system_user}"
48-
image: odoo:\${ODOO_VERSION}
88+
build:
89+
context: .
90+
args:
91+
ODOO_VERSION: \${ODOO_VERSION}
4992
depends_on:
5093
db:
5194
condition: service_healthy
@@ -118,13 +161,18 @@ chmod 600 "$domain_root_path/domains/$subdomain.$domain/odoo/.env"
118161
```
119162

120163
```.sh
121-
# Create directory
164+
# Create config directory
122165
sudo mkdir -p $domain_root_path/domains/$subdomain.$domain/odoo/config
123166

124-
# Create odoo.conf
167+
# Generate addons_path from submodules (converts ./oca/repo to /mnt/extra-addons/oca/repo)
168+
cd $domain_root_path/domains/$subdomain.$domain/odoo/addons
169+
ADDONS_PATH=$(find . -mindepth 2 -maxdepth 2 -type d | grep -E "^\./oca/|^\./custom/" | sed 's|^\./|/mnt/extra-addons/|' | tr '\n' ',' | sed 's/,$//')
170+
cd $domain_root_path/domains/$subdomain.$domain/odoo
171+
172+
# Create odoo.conf (addons_path includes OCA submodule paths)
125173
cat <<EOF > "$domain_root_path/domains/$subdomain.$domain/odoo/config/odoo.conf"
126174
[options]
127-
addons_path = /usr/lib/python3/dist-packages/odoo/addons,/mnt/extra-addons
175+
addons_path = /usr/lib/python3/dist-packages/odoo/addons,$ADDONS_PATH
128176
data_dir = /var/lib/odoo
129177
admin_passwd = $odoo_master_password
130178
db_host = $database_host
@@ -147,13 +195,19 @@ EOF
147195
```
148196

149197
```.sh
198+
# Create data directories
199+
sudo mkdir -p "$domain_root_path/domains/$subdomain.$domain/odoo/data"
200+
sudo mkdir -p "$domain_root_path/domains/$subdomain.$domain/odoo/postgres"
201+
150202
# Get Odoo container UID/GID
151203
odoo_uid=$(docker run --rm odoo:$odoo_version id -u)
152204
odoo_gid=$(docker run --rm odoo:$odoo_version id -g)
153205
echo "Odoo UID: $odoo_uid, GID: $odoo_gid"
154206

155-
# Change ownership
207+
# Change ownership (after git operations are complete)
156208
sudo chown -R $odoo_uid:$odoo_gid "$domain_root_path/domains/$subdomain.$domain/odoo/data"
209+
sudo chown -R $odoo_uid:$odoo_gid "$domain_root_path/domains/$subdomain.$domain/odoo/addons"
210+
sudo chown -R $odoo_uid:$odoo_gid "$domain_root_path/domains/$subdomain.$domain/odoo/config"
157211

158212
# Get PostgreSQL container UID
159213
postgres_uid=$(docker run --rm postgres:16 id -u)
@@ -164,6 +218,12 @@ echo "Postgres UID: $postgres_uid, GID: $postgres_gid"
164218
sudo chown -R $postgres_uid:$postgres_gid "$domain_root_path/domains/$subdomain.$domain/odoo/postgres"
165219
```
166220

221+
```.sh
222+
# Build custom Odoo image
223+
cd $domain_root_path/domains/$subdomain.$domain/odoo
224+
docker compose build
225+
```
226+
167227
```.sh
168228
# Initialize Odoo database with core modules
169229
cd $domain_root_path/domains/$subdomain.$domain/odoo
@@ -243,6 +303,7 @@ sudo systemctl reload nginx
243303

244304
# Update Odoo to latest patch
245305
# docker compose pull
306+
# docker compose build
246307
# docker compose up -d
247308

248309
# Access Odoo shell
@@ -252,6 +313,38 @@ sudo systemctl reload nginx
252313
# docker exec odoo_postgres_${system_user} pg_dump -U $database_username $database_name > backup.sql
253314
```
254315

316+
### Update OCA Submodules
317+
318+
```.sh
319+
# Update all OCA submodules to latest
320+
cd $domain_root_path/domains/$subdomain.$domain/odoo/addons
321+
git submodule update --remote --merge
322+
git add .
323+
git commit -m "Update OCA submodules"
324+
325+
# Rebuild Docker image (in case requirements.txt changed)
326+
cd $domain_root_path/domains/$subdomain.$domain/odoo
327+
docker compose build
328+
docker compose up -d
329+
```
330+
331+
### Add New OCA Submodule
332+
333+
```.sh
334+
# Example: add a new OCA repo
335+
cd $domain_root_path/domains/$subdomain.$domain/odoo/addons
336+
git submodule add --branch $odoo_version https://github.com/OCA/account-financial-tools.git oca/account-financial-tools
337+
git commit -m "Add OCA account-financial-tools"
338+
339+
# Update odoo.conf to include new path
340+
# Add: /mnt/extra-addons/oca/account-financial-tools
341+
342+
# Rebuild and restart
343+
cd $domain_root_path/domains/$subdomain.$domain/odoo
344+
docker compose build
345+
docker compose up -d
346+
```
347+
255348
## Uninstall
256349

257350
```.sh
@@ -264,5 +357,5 @@ sudo systemctl reload nginx
264357
# sudo rm -rf $domain_root_path/domains/$subdomain.$domain/odoo
265358

266359
# Confirm docker is not running
267-
docker ps
360+
# docker ps
268361
```

0 commit comments

Comments
 (0)