Skip to content

Instantly share code, notes, and snippets.

View mao-odoo's full-sized avatar

Moens Alexandre mao-odoo

  • Belgium, Grand-Rosière-Hottomont
View GitHub Profile
@mao-odoo
mao-odoo / rpn.py
Last active March 22, 2021 09:01
python rpn with support for unary and ternary operator (+ ready for more )
import inspect
ops = {
"+": lambda a, b: a + b,
"-": lambda a, b: a - b,
"x": lambda a, b: a * b,
"/": lambda a, b: a / b,
"sqrt": lambda a: a ** 0.5,
"ternary_operator": lambda a, b, c: a + b + c + 1,
}
@mao-odoo
mao-odoo / min_postgres_version_for_odoo.py
Last active April 19, 2024 15:55
Minimal postgresql version for each Odoo version
# Minimal postgresql version for each Odoo version
MINIMAL_PG_VERSIONS = {
"6.0": "9.5",
"7.0": "9.5",
"8.0": "9.5",
"9.0": "9.5",
"10.0": "9.5",
"11.0": "9.5",
"12.0": "9.5",
"saas~12.3": "10",
@mao-odoo
mao-odoo / a.shell
Created May 17, 2021 11:36
Am I running this commit?
git merge-base --is-ancestor <commit_you_are_interrested_in> HEAD && echo "yes" || echo "no"
import xmlrpc.client; xmlrpc.client.ServerProxy('https://<domain_name>/xmlrpc/2/common').version()
@mao-odoo
mao-odoo / send_filestore_to_remote.sh
Created September 1, 2021 08:06
send filestore to odoo.sh in smaller, compressed parts
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
@mao-odoo
mao-odoo / registry_signalling.py
Last active August 23, 2023 11:47
odoo invalidate registry
# 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()

Create a server action record that allows user to uninstall many apps at once

Action Name

Uninstall Modules

Model

Module (type ir_module to get to the right one)

@mao-odoo
mao-odoo / http_server_auth.py
Last active January 23, 2024 09:53 — forked from mauler/http_server_auth.py
Python3 http.server supporting basic HTTP Auth (username/password (mandatory))
#!/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
@mao-odoo
mao-odoo / list_custom_apps_installed_odoosh.sh
Last active April 19, 2024 15:40
get a list of all custom apps installed on a odoo.sh database
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
@mao-odoo
mao-odoo / autoretryrsyncuntilsuccess.sh
Last active October 2, 2024 10:09
auto retry rsync until success
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