Create a server action record that allows user to uninstall many apps at once
Uninstall Modules
Module (type ir_module to get to the right one)
| #!/usr/bin/env python3 | |
| import sys | |
| import os | |
| import time | |
| import psycopg2 | |
| def walk_filestore(filestore_path): | |
| for root, dirs, files in os.walk(filestore_path): | |
| if "checklist" not in root.split("/")[-2:] and files: | |
| for file in files: |
| path_to_odoo_code=<The_path_to_the_odoo_code> | |
| db_name=<The_name_of_the_database> | |
| neutered_apps=$(find $path_to_odoo_code -name neutralize.sql | jq -nRr '[inputs] | map(split("/")[-3]) | join(",")'); | |
| for module in $(psql -tAqX -d $db_name -c "select name from ir_module_module where name = ANY('{$neutered_apps}'::text[]) and state not in ('uninstalled', 'uninstallable') order by name;"); do | |
| echo "\n\n----- $module -----"; | |
| cat $(find $path_to_odoo_code/**/$module/data/neutralize.sql); | |
| done |
| while ! rsync <put_all_rsync_parameter_here> ; do echo 'rsync failed, retrying'; sleep 3; done; | |
| # use --info=progress2 to see the evolution in betwen attemptsd |
| standard_apps=$(find /home/odoo/src/{odoo,enterprise,themes} -name __manifest__.py | jq -nRr '[inputs] | map(split("/")[-2]) | join(",")'); psql -c "select name, state from ir_module_module where NOT (name = ANY('{$standard_apps,studio_customization}'::text[]) ) and state not in ('uninstalled', 'uninstallable') order by name;" | |
| # explanation of the code | |
| # find /home/odoo/src/{odoo,enterprise,themes} -name "__manifest__.py" --> list the path to each odoo standard modules | |
| # in Jq | |
| # [inputs] --> transforms the input text to an array of lines | |
| # map(split("/")[-2]) --> for each line, get the directory's name |
| #!/usr/bin/env python3 | |
| # Extended python -m http.serve with --username and --password parameters for | |
| # basic auth, based on https://gist.github.com/fxsjy/5465353 | |
| from functools import partial | |
| from http.server import SimpleHTTPRequestHandler, test | |
| import base64 | |
| import os |
| # usefull when apps are in a weird state that requires changing the state in SQL | |
| # or if there was an (un)install issue and the database is left in a weird state | |
| # use this in the shell if you can't restart the odoo instance (because of mulitple tenants for example) | |
| env.cr.commit() | |
| env.registry.registry_invalidated = True | |
| env.registry.signal_changes() |
| sync_filestore_to_remote() { | |
| # sends a local filestore to a remote server in batches (1 per filestore folder) | |
| # the goal is too use less additional space than a big zip file, while not sending | |
| # each file individually (which might trigger a network rate limiting) | |
| args=("$@") | |
| ELEMENTS=${#args[@]} | |
| if [ $ELEMENTS -ne 3 ]; then | |
| echo "Usage: sync_filestore_to_remote local_filestore_path remote_host remote_filestore_path" | |
| exit 1 |
| import xmlrpc.client; xmlrpc.client.ServerProxy('https://<domain_name>/xmlrpc/2/common').version() |
| git merge-base --is-ancestor <commit_you_are_interrested_in> HEAD && echo "yes" || echo "no" |