Skip to content

Commit 2b26fd6

Browse files
committed
feat(odoo): add docker-odoo-clear-rules script to clear noupdate security rules and update install tasks
1 parent b9f73ef commit 2b26fd6

4 files changed

Lines changed: 56 additions & 2 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
script=$(basename "$0")
5+
version="1.0.1"
6+
7+
help() {
8+
echo
9+
echo "$script"
10+
echo
11+
echo 'Description: Clear all security rules of Odoo database.'
12+
echo "Syntax: $script [-c|-d|-V|help]"
13+
echo 'Example: $script -c odoo01 -d erp'
14+
echo 'options:'
15+
echo ' -c Docker container. Defaults to '\''odoo'\''.'
16+
echo ' -d Database name. Defaults to '\''odoo'\''.'
17+
echo ' -v Show $script version.'
18+
echo " help Show $script manual."
19+
echo
20+
}
21+
22+
if [[ "$1" == 'help' ]]; then
23+
help
24+
exit
25+
fi
26+
27+
container=odoo
28+
database=odoo
29+
30+
while getopts ':c: :d: :V' opt; do
31+
case $opt in
32+
c) container="$OPTARG" ;;
33+
d) database="$OPTARG" ;;
34+
V) echo "$script version $version"
35+
exit 0
36+
;;
37+
\?) echo "Invalid option -$OPTARG" >&2
38+
help
39+
exit;;
40+
esac
41+
done
42+
43+
echo "Delete all noupdate security rules for $database in $container :"
44+
docker exec "$container" /bin/bash -c "psql postgresql://\$PGUSER:\$PGPASSWORD@\$PGHOST/$database -c \"DELETE FROM ir_rule
45+
WHERE id IN (
46+
SELECT res_id
47+
FROM ir_model_data
48+
WHERE model = 'ir.rule'
49+
AND noupdate = TRUE
50+
);\""
51+
52+
echo "Update all modules with: docker-odoo-update -c $container -d $database -u all"

roles/odoo/files/docker-odoo-clear-views

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ help() {
88
echo
99
echo "$script"
1010
echo
11-
echo 'Description: Clear all views of Odoo instance.'
11+
echo 'Description: Clear all views of Odoo database.'
1212
echo "Syntax: $script [-c|-d|-V|help]"
1313
echo 'Example: $script -c odoo01 -d erp'
1414
echo 'options:'
@@ -52,5 +52,5 @@ echo "Delete all active views for $database in $container :"
5252
docker exec "$container" /bin/bash -c "psql postgresql://\$PGUSER:\$PGPASSWORD@\$PGHOST/$database -c \"DELETE FROM report_layout WHERE view_id IN (SELECT id FROM ir_ui_view WHERE active = TRUE);\""
5353
docker exec "$container" /bin/bash -c "psql postgresql://\$PGUSER:\$PGPASSWORD@\$PGHOST/$database -c \"WITH RECURSIVE views_to_delete AS (SELECT id, inherit_id FROM ir_ui_view WHERE active = TRUE AND inherit_id IS NULL UNION ALL SELECT v.id, v.inherit_id FROM ir_ui_view v JOIN views_to_delete p ON v.inherit_id = p.id) DELETE FROM ir_ui_view WHERE id IN (SELECT id FROM views_to_delete);\""
5454

55-
echo "Update all modules with: docker-odoo-update -c $container -d $database -u base"
55+
echo "Update all modules with: docker-odoo-update -c $container -d $database -u all"
5656
echo "Then unarchive views with prefix 'mint_system' and 'Odoo Studio:'."

roles/odoo/files/install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ scripts=(
77
docker-odoo-backup
88
docker-odoo-clear-assets
99
docker-odoo-clear-views
10+
docker-odoo-clear-rules
1011
docker-odoo-cloc
1112
docker-odoo-drop
1213
docker-odoo-duplicate

roles/odoo/tasks/odoo_scripts.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- docker-odoo-backup
1414
- docker-odoo-clear-assets
1515
- docker-odoo-clear-views
16+
- docker-odoo-clear-rules
1617
- docker-odoo-cloc
1718
- docker-odoo-drop
1819
- docker-odoo-duplicate

0 commit comments

Comments
 (0)