#!/bin/zsh function help() { echo echo "$1 [options]" echo echo "commands:" echo column -t -s"|" ./task.md | tail -n +3 echo } function disable-auto-install() { echo "Disable auto install for all enterprise modules." find ./enterprise -type f -name '__manifest__.py' -exec sed -i '' $'s/\'auto_install\': True,/\'auto_install\': False,/g' {} + } function venv-init() { python3 -m venv venv source venv/bin/activate } function activate-venv() { source ../venv/bin/activate } function locale() { export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 } function install-src() { cd odoo activate-venv pip install setuptools psycopg2-binary watchdog phonenumbers pip install -r requirements.txt } function start-shell() { if test -z "$1" then echo "\$1 is empty" else cd odoo locale ./odoo-bin shell -d $1 --db_host=localhost -r odoo -w odoo --addons-path='../addons' --no-http fi } function init-db() { cd odoo locale activate-venv && ./odoo-bin --init base -d odoo --db_host=localhost -r odoo -w odoo --stop-after-init } function start-src() { cd odoo locale activate-venv && ./odoo-bin --config=../config/odoo-src.conf --db_host=localhost -r odoo -w odoo --dev=all } function update-module() { cd odoo locale activate-venv && ./odoo-bin -d $1 -u $2 --db_host=localhost -r odoo -w odoo --stop-after-init --no-http } function scaffold-src() { if test -z "$1" then echo "\$1 is empty" else cd odoo python3 odoo-bin scaffold $1 ../addons fi } function drop-db() { if test -z "$1" then echo "\$1 is empty" else psql postgres://odoo:odoo@localhost/postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '$1';" psql postgres://odoo:odoo@localhost/postgres -c "DROP DATABASE $1;" fi } function send-support-mail() { curl smtp://localhost --mail-from admin@yourcompany.example.com --mail-rcpt support@localhost --upload-file ./data/email.txt } function clear-assets() { if test -z "$1" then echo "\$1 is empty" else echo "Delete these assets:" psql postgres://odoo:odoo@localhost/$1 -c "select id,name from ir_attachment where res_model='ir.ui.view' and name like '%assets_%';" psql postgres://odoo:odoo@localhost/$1 -c "delete from ir_attachment where res_model='ir.ui.view' and name like '%assets_%';" fi } function upload-module() { if [ "$1" = "certificate_planer" ]; then rsync -av -e ssh --exclude='.git' addons/certificate_planer hermes.mint-system.com:/usr/share/odoo05/addons/ fi } case "$1" in disable-auto-install) disable-auto-install ;; checkout) git checkout $2 && git submodule update --init ;; start) docker-compose up -d ;; stop) docker-compose stop ;; kill) docker-compose down -v ;; logs) docker logs odoo -f ;; start-db) docker-compose up -d db pgadmin ;; venv-init) venv-init ;; install-src) install-src ;; init-db) init-db ;; start-src) start-src ;; start-shell) start-shell $2 ;; update-module) update-module $2 $3 ;; upload-module) upload-module $2 ;; scaffold-src) scaffold-src $2 ;; drop-db) drop-db $2 ;; compile-managed-modules) ./scripts/compile-managed-modules ;; copy-managed-modules) ./scripts/copy-managed-modules ;; remove-managed-modules) ./scripts/remove-managed-modules ;; send-support-mail) send-support-mail ;; clear-assets) clear-assets $2 ;; *) help task exit 1 esac