diff --git a/addons/demand_planner b/addons/demand_planner index d6e2894d..92435f40 160000 --- a/addons/demand_planner +++ b/addons/demand_planner @@ -1 +1 @@ -Subproject commit d6e2894d9df6274a71dfb6f61d11229c1e7ee1b9 +Subproject commit 92435f4086a25dc40960581a80b11e4a71780516 diff --git a/task b/task index 4d866829..80272f24 100755 --- a/task +++ b/task @@ -14,8 +14,14 @@ echo PATH="$PATH:./odoo" GIT_TAG=0 GIT_BRANCH=$(git symbolic-ref --short -q HEAD) +export POSTGRES_USER=odoo +export POSTGRES_PASSWORD=odoo export ODOO_REVISION=$GIT_BRANCH +if [ -a ".env" ]; then + export $(cat .env | sed 's/#.*//g' | xargs) +fi + function get-module-version() { if test -z "$1" then @@ -240,7 +246,7 @@ function clear-assets() { docker exec db psql postgres://odoo:odoo@localhost/$DATABASE -c "select id,name from ir_attachment where res_model='ir.ui.view' and name like '%assets_%';" docker exec db psql postgres://odoo:odoo@localhost/$DATABASE -c "delete from ir_attachment where res_model='ir.ui.view' and name like '%assets_%';" - echo "Restart your docker service". + echo "Restart your docker service." } function convert-database() { @@ -430,6 +436,19 @@ function git-list-submodules() { git config --file .gitmodules --get-regexp url | sed -e 's/submodule.//g' -e 's/.url//g' | awk '{ print $1 "," $2}' } +function patch-database() { + if test -z "$1"; then echo "\$1 is empty"; exit; fi + if test -z "$2"; then echo "\$1 is empty"; exit; fi + + # Generate view name from filename + FILENAME=$(basename $2) + + echo "Apply patch $FILENAME to Database $1." + cat $2 | docker exec -i db psql postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost/$1 + echo "Patching database succeeded" +} + + case "$1" in disable-auto-install) disable-auto-install @@ -539,6 +558,9 @@ case "$1" in upload-module) upload-module $2 $3 ;; + patch-database) + patch-database $2 $3 + ;; *) help task exit 1 diff --git a/task.md b/task.md index fdd03384..817c14d9 100644 --- a/task.md +++ b/task.md @@ -19,6 +19,7 @@ | lint-module | [path] | Run pylint odoo for module. | | logs | | Tail Odoo Docker container logs. | | odoo-cloc | [db] | Count custom line of codes. | +| patch-database | [db] [path] | Apply sql file to database | | release-module | [path] | Create GitHub release for a module. | | remove-module | [db] [name] | Remove target Odoo module. | | remove-submodule | [path] | Remove git submodule. |