Last active
August 29, 2015 14:02
-
-
Save katyukha/4116e11a5a1e322c2542 to your computer and use it in GitHub Desktop.
New module generator for OpenERP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Usage: | |
# new_module.bash <module_name> [root] | |
# Where 'root' arg is root directory to place module in. By default it is 'custom_addons' | |
# | |
# Guess directory script is placed in | |
F=`readlink -f $0` | |
BASEDIR=`dirname $F` | |
LOGDIR=$BASEDIR/logs | |
PIDFILE=$BASEDIR/openerp-server.pid | |
LOGFILE=$LOGDIR/openerp-server.log | |
CUSTOM_ADDONS_DIR=$BASEDIR/custom_addons | |
set -e; | |
function generate_oerp_py { | |
MOD_PATH=$1 | |
cat > $MOD_PATH/__openerp__.py << EOF | |
# -*- coding: utf-8 -*- | |
{ | |
'author': '`whoami`', | |
'category': 'Added functionality', | |
'description': """ | |
--- | |
""", | |
'website': '', | |
'images': [], | |
'depends' : [], | |
'data': [], # Place xml views here | |
'demo': [], | |
'installable': True, | |
'auto_install': False, | |
} | |
EOF | |
} | |
function generate_gitignore { | |
MOD_PATH=$1 | |
cat > $MOD_PATH/.gitignore << EOF | |
*.pyc | |
*.swp | |
*.idea/ | |
*~ | |
*.swo | |
*.pyo | |
EOF | |
} | |
function create_module { | |
NEW_MODULE_NAME=$1 | |
NEW_MODULE_DIR=$2 | |
if [ -z $NEW_MODULE_DIR ]; then | |
NEW_MODULE_DIR=$CUSTOM_ADDONS_DIR; | |
fi | |
NEW_MODULE_PATH=$NEW_MODULE_DIR/$NEW_MODULE_NAME | |
if [ -d "$NEW_MODULE_PATH" ]; then | |
echo "Module $NEW_MODULE_NAME already exists in module path $NEW_MODULE_PATH"; | |
exit -1; | |
fi; | |
mkdir $NEW_MODULE_PATH; | |
generate_oerp_py $NEW_MODULE_PATH; | |
generate_gitignore $NEW_MODULE_PATH; | |
mkdir $NEW_MODULE_PATH/models; | |
mkdir $NEW_MODULE_PATH/views; | |
mkdir $NEW_MODULE_PATH/security; | |
mkdir $NEW_MODULE_PATH/reports; | |
echo "import models" > $NEW_MODULE_PATH/__init__.py; | |
touch "$NEW_MODULE_PATH/models/__init__.py"; | |
} | |
create_module $1 $2; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment