Untitled

mail@pastecode.io avatar
unknown
python
a year ago
824 B
4
Indexable
# my_module.py

from odoo import api, SUPERUSER_ID

def post_install_hook(cr, registry):
    env = api.Environment(cr, SUPERUSER_ID, {})
    
    # Create schema
    env.cr.execute("CREATE SCHEMA IF NOT EXISTS felsv;")

    # Create user
    env.cr.execute("CREATE USER felsv WITH PASSWORD 'your_password';")

    # Grant necessary privileges to the user on the schema
    env.cr.execute("GRANT ALL PRIVILEGES ON SCHEMA felsv TO felsv;")

def uninstall_hook(cr, registry):
    env = api.Environment(cr, SUPERUSER_ID, {})

    # Revoke privileges before dropping the schema
    env.cr.execute("REVOKE ALL PRIVILEGES ON SCHEMA felsv FROM felsv;")

    # Drop the schema
    env.cr.execute("DROP SCHEMA IF EXISTS felsv CASCADE;")

    # Drop the user
    env.cr.execute("DROP USER IF EXISTS felsv;")
Leave a Comment