This repository was archived by the owner on Aug 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
94 lines (82 loc) · 3.07 KB
/
justfile
File metadata and controls
94 lines (82 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
set shell := ["/usr/bin/env", "bash", "-c"]
set quiet
# Variables
ODOO_BIN := "./odoo/odoo-bin"
ADDONS_PATH := "odoo/addons,custom_addons"
DB_NAME := "odoo-dev"
DB_HOST := "127.0.0.1"
DB_PORT := "5433"
# First-time setup: drop database, recreate, and initialize with base module
init:
@echo "Initializing Odoo database for first time..."
@echo "Dropping existing database if it exists..."
-dropdb -h {{DB_HOST}} -p {{DB_PORT}} -U "$USER" "{{DB_NAME}}" 2>/dev/null || true
@echo "Creating fresh database..."
createdb -h {{DB_HOST}} -p {{DB_PORT}} -U "$USER" "{{DB_NAME}}"
@echo "Initializing Odoo with base module..."
"{{ODOO_BIN}}" \
--addons-path="{{ADDONS_PATH}}" \
--db_host={{DB_HOST}} \
--db_port={{DB_PORT}} \
--db_user="$USER" \
-d "{{DB_NAME}}" \
-i base \
--stop-after-init \
--without-demo=all
@echo "Database initialized successfully!"
reset:
@echo "Resetting Odoo database..."
-dropdb -h {{DB_HOST}} -p {{DB_PORT}} -U "$USER" "{{DB_NAME}}" 2>/dev/null || true
createdb -h {{DB_HOST}} -p {{DB_PORT}} -U "$USER" "{{DB_NAME}}"
"{{ODOO_BIN}}" -d "{{DB_NAME}}" -i base --stop-after-init --without-demo=all
run:
@echo "Starting Odoo server with extra args: $@"
"{{ODOO_BIN}}" \
--addons-path="{{ADDONS_PATH}}" \
-d "{{DB_NAME}}" \
--dev=all \
"$@"
update modules:
@echo "Updating Odoo modules: {{modules}}..."
"{{ODOO_BIN}}" --addons-path="{{ADDONS_PATH}}" -d "{{DB_NAME}}" -u "{{modules}}" --stop-after-init
@echo "Modules updated. Restart Odoo server to apply changes."
install modules:
@echo "Installing Odoo modules: {{modules}}..."
"{{ODOO_BIN}}" --addons-path="{{ADDONS_PATH}}" -d "{{DB_NAME}}" -i "{{modules}}" --stop-after-init
@echo "Modules installed. Restart Odoo server to apply changes."
shell:
@echo "Launching Odoo shell..."
"{{ODOO_BIN}}" shell --addons-path="{{ADDONS_PATH}}" -d "{{DB_NAME}}"
test modules:
@echo "Running tests for Odoo modules: {{modules}}..."
"{{ODOO_BIN}}" --addons-path="{{ADDONS_PATH}}" -d "{{DB_NAME}}" -u "{{modules}}" --test-enable --stop-after-init
@echo "Tests completed."
scaffold module_name:
@echo "Scaffolding new Odoo module: {{module_name}} in custom_addons/..."
mkdir -p custom_addons
"{{ODOO_BIN}}" scaffold "{{module_name}}" "custom_addons"
@echo "Module '{{module_name}}' created. Then run `just install-modules {{module_name}}` to install it."
status:
@echo "Database status:"
@echo "Database: {{DB_NAME}}"
@if psql -h {{DB_HOST}} -p {{DB_PORT}} -U "$USER" -lqt \
| cut -d \| -f 1 \
| grep -qw "{{DB_NAME}}"; then \
echo "✓ Database exists"; \
echo "Tables:"; \
psql -h {{DB_HOST}} -p {{DB_PORT}} -U "$USER" -d "{{DB_NAME}}" -c "\dt" \
| head -10; \
else \
echo "✗ Database does not exist"; \
fi
db-kill:
@echo "Killing all database connections..."
-psql -h {{DB_HOST}} -p {{DB_PORT}} \
-c "SELECT pg_terminate_backend(pid) \
FROM pg_stat_activity \
WHERE datname = '{{DB_NAME}}' \
AND pid <> pg_backend_pid();" \
2>/dev/null || true
db-restart:
@echo "Restarting PostgreSQL..."
pg_ctl -D ./.pgdata restart -m fast