Odoo startup script for Ubuntu

This is a startup script you can use for Odoo (formerly known as OpenErp) on Ubuntu:

#!/bin/sh

### BEGIN INIT INFO
# Provides:             openerp-server
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Should-Start:         $network
# Should-Stop:          $network
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Enterprise Resource Management software
# Description:          Open ERP is a complete ERP and CRM software.
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
# DAEMON=/usr/bin/openerp-server
DAEMON=/home/openerp/odoo/openerp-server
NAME=openerp-server
DESC=openerp-server
CONFIG=/etc/openerp/openerp-server.conf
LOGFILE=/var/log/openerp/openerp-server.log
USER=openerp
PIDFILE=/var/run/${NAME}.pid

test -x ${DAEMON} || exit 0

set -e

checkpid() {
  [ -f $PIDFILE ] || return 1
  pid=`cat $PIDFILE`
  [ -d /proc/$pid ] && return 0
  return 1
}

do_start () {
    echo -n "Starting ${DESC}: "
    start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid ${USER} --background --make-pidfile --exec ${DAEMON} -- --config=${CONFIG} --logfile=${LOGFILE}
    echo "${NAME}."
}

do_stop () {
    echo -n "Stopping ${DESC}: "
    start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo
    echo "${NAME}."
}

do_status() {

  echo -n "Checking $NAME: "

  checkpid

  if [ $? -eq 1 ]; then
    echo "stopped."
  else
    echo "running."
  fi

}

# Main
case "${1}" in
    start)
        do_start
        ;;

    stop)
        do_stop
        ;;

    restart|force-reload)
        echo -n "Restarting ${DESC}: "
        do_stop
        sleep 1
        do_start
        ;;

    status)
        do_status
        ;;

    *)
        N=/etc/init.d/${NAME}
        echo "Usage: ${NAME} {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

 

 

Advertisements
Posted in Uncategorized | Leave a comment

How to fix your Microsoft Comfort Curve 2000 Keyboard

This post is moving to my other blog here.

The Microsoft Comfort Curve 2000 Keyboard is a very nice keyboard – short movement, slightly curved, wired (no annoying batteries!), USB, … and definitely my keyboard of choice… except for one thing: the ‘c’ or ‘n’ keys stop working occassionally, as experienced by many users of this keyboard. Here are two ways that will usually fix the problem:

  1. The unorthodox but quick method: give the keyboard a whack or a drop: hold it about 5 inches above the desk, not exactly parallel/flat, and drop it so that one corner hits first and it bounces around.
  2. Unscrew the back of the keyboard, pull off the back, separate the plastic, gently dust it, and put it back together.

These two actions just listed generaly do the trick, but the problem, according to this post, is due to static build-up on the inner plastic. Changing drivers, USB ports, cables, etc. isn’t going to fix this problem. Unfortunately, neither is buying another Comfort Curve 2000 keyboard. So as a last resort:

3. Buy the Microsoft Comfort Curve 3000 Keyboard instead.

Posted in Hardware | 16 Comments

Guide to using LaunchPad for OpenERP development

  1. Create an account for yourself on LaunchPad.
  2. Upload your ssh signature as per https://help.launchpad.net/YourAccount/CreatingAnSSHKeyPair
  3. Log in to Launchpad: On Centos:
    bzr launchpad-login <your-launchpad-login>

    On Ubuntu:

    bzr whoami <your-launchpad-login>
  4. Get the latest trunk source code: For the server:
    bzr branch lp:~openerp/openobject-server/trunk

    For the modules:

    bzr branch lp:openobject-addons
  5. To update (cf. svn update, i.e. freshen) your branch later:
    bzr pull

How to contribute your changes to the OpenERP Community

  1. Join the OpenERP Community here: https://launchpad.net/~openerp-community
  2. You should probably create a bug or mod with a Blueprint on Launchpad in the appropriate project.
  3. Make your changes.
    vi addons/account/account.py
  4. Commit to your local branch.
    cd addons
    bzr ci -m "Testing Modifications"
  5. Push your changes up to Launchpad.
    cd addons
    bzr push lp:~openerp-community/openobject-addons/YOURLOGIN_YOURBRANCHNAME

    Don’t forget to set the status of your branch (new, experimental, development, mature, …) so that contributors know what they can use or not.

  6. Bind your local branch to the one on Launchpad so that future commits will be applied directly to the one on Launchpad.
    bzr bind lp:~openerp-community/openobject-addons/YOURLOGIN_YOURBRANCHNAME
  7. Further editing would then follow these steps:
    bzr pull    # Get modifications on your branch from others
    EDIT STUFF
    bzr ci    # commit your changes on your public branch
    OR
    bzr ci --fixes=lp:453123   # Where 453123 is a bug ID
  8. Update your branch from its parent branch:
    bzr merge
  9. Once your branch is mature, mark it as mature in the web interface of launchpad and request for merging in the official release. Your branch will be reviewed by a commiter and then the quality team to be merged in the official release.

More Information

Posted in OpenERP | Leave a comment

How to install and use Eclipse for Python development and debugging with OpenERP

How to install Eclipse on Windows

  • Download and install the Java SE JDK
  • Download and install Eclipse Classic 3.5.1 or later from http://eclipse.org
  • In Eclipse, install PyDev by going to Help / Install new software / Add.
    • Name: Pydev
    • Location: pydev.org/updates.
    • Then tick PyDev, Next, Install PyDev for Eclipse.
    • After it has installed, go to Windows / Preference / Pydev / Interpreter – Python; go to Python Interpreters.
    • Click the “Auto Config” button. It should list a lot of directories. Make sure you tick the directory for PyDev; it is probably the first or last directory in the list, and probably the only one not yet ticked.

How to install Eclipse on Centos 5.5

These instructions are for Centos 5.5.

  • Install the GUI Desktop, e.g.:
    # yum groupinstall 'X Window System'
    # yum groupinstall 'Gnome Desktop environment'
  • Install Java:
    # yum install java
  • Install Eclipse:
    # yum install eclipse-platform
  • Run Eclipse in the GUI environment.
    # init 5
  • Go to Help / Updates / Find and Install…; select Search for new features to install.
  • Click on New Remote Site.
    • Name: Pydev
    • Location: pydev.org/updates.
  • Hit Finish.
  • Expand PyDev. Select PyDev; you do not need to select ‘PyDev Mylyn Integration’.
  • Hit Finish; it should download and install PyDev.
  • After it has installed, go to Windows / Preference / Pydev / Interpreter – Python; go to Python Interpreters.
  • Click the “Auto Config” button. It should list a lot of directories. Make sure you tick the directory for PyDev; it is probably the first or last directory in the list, and probably the only one not yet ticked.

How to setup up Ecplise for debugging on Linux

If you are logged into a graphical desktop, you can debug OpenERP using the following procedure:

  • Copy ~openerp/.openerp_serverrc to your home directory.
  • Edit /<your-home-directory>/.openerp_serverrc; change the entries for root_path and addons_path as appropriate, e.g.:
    • root_path = /<your-home-directory>/eclipse.workspace/OpenERP/src
    • addons_path = /<your-home-directory>/eclipse.workspace/OpenERP/src/addons
    • Create a new project in Eclipse.
    • Copy all the OpenERP source into the src directory of the project, including all the sub-directories.
    • It is easier if you start Eclipse in the directory where your project lives. There may be a better way to do this, but you could:
      • Stop Eclipse
      • Create a shell script, called something such as start_eclipse, in your PATH with contents like this:
        #!/bin/sh
        cd $HOME/work/eclipse.workspace/OpenERP/src
        exec eclipse
      • Then run start_eclipse from your command-line (or tell XMing to run it).
      • Add all the modules and code to the project:
        • Right-click on the src directory in the PyDev Package Explorer.
        • Go to New / File / Advanced and tick Link to file in the file system.
        • Click on Browse and add openerp-server.py.
        • Do the same for all the other *.py files in the source directory.
        • Click on the src directory in the PyDev Package Explorer.
        • Go to New / Folder / Advanced and tick Link to folder in the file system.
        • Click on Browse and add the addons directory.
        • Do the same for all the other directories.
      • In the top right, select the Debug perspective.
      • Setup a Debug configuration in Eclipse:
        • In Eclipse, go to Run / Debug….
        • Select Python Run.
        • Click the New button.
        • Give the configuration a Name.
        • Select your OpenERP project.
        • For Main Module, browse to openerp-server.py
        • On the Arguments tab, add start-up arguments that you may want; see /etc/init.d/openerp-server for arguments.
          E.g. you may use: –logfile=/var/log/openerp-server.log –log-level=debug.
        • Apply the changes and Close.
      • Set breakpoints in your source files as desired.
      • To start debugging, press the Debug toolbar icon or go to Run/Debug… and press the Debug button.

How to run Eclipse on Linux in a window on Windows using X-Windows

To turn your Linux’s installation of Eclipse from your Windows PC, download and install the XMing server. This actually works quite well – the responsiveness is better than running a Gnome desktop inside a Virtual Machine. Run Xlaunch and tell it to run eclipse or your start_eclipse shell script in a multi-window environment.

Install Code Snippets

Download and install code snippets from: http://code.google.com/p/openerp-eclipse-template/

Code snippets are shortcuts for adding template code.

Gotcha’s

If you create a file in Eclipse, the Windows version, and it saves in DOS format (as opposed to Unix format end-of-lines), then OpenERP 5 will not detect or load the module. You can use Unix’s file command to tell you which files have these unwanted CRLF’s:

E.g. these files had problems (note the CRLF line terminators notes):

/home/phil/openerp/addons/my_product_kit # file *.py *.xml
__init__.py:              ASCII Java program text, with CRLF line terminators
my_product_kit.py:        ASCII Java program text, with CRLF line terminators

but these did not:

/home/phil/openerp/addons/my_product_kit # file works/*
works/__init__.py:         ASCII English text
works/my_territory.py:     ASCII Java program text
works/my_territory.xml:    ASCII text
works/__terp__.py:         ASCII text

IDE’s that you can use for Python

Here’s a list of IDE’s that you can use for Python:

  • Eclipse on Windows
  • Eclipse on Linux
  • Aptana – based on Eclipse
  • Netbeans
  • Visual Studio 2010 with IronPython

Python Code Editors

Here’s a list of editors for Python code:

  • vim
  • gedit

How to set up Samba

How to set up Samba on Centos 5 so you can share a drive from a Linux box to a Windows PC. This is so that you can run Eclipse on your PC to edit files on your Linux OpenERP server.

# service smb start
# smbpasswd -a philu
# setsebool -P samba_enable_home_dirs
# setsebool -P samba_export_all_rw on
# chcon -R -t samba_share_t /home/philu

Then mapped a network drive from Windows, using:

  • User: \username
  • Share: \\openerp.example.com\username

Debugging

Use your IDE’s tools, or the Python debugger: http://docs.python.org/library/pdb.html

See Also

Posted in OpenERP | 1 Comment

Where are the configuration files for OpenERP?

OpenERP configuration files on Centos 5.5

  • /etc/openerp-web.cfg
  • /etc/init.d/openerp-web
  • /etc/init.d/openerp-server
  • ~openerp/.openerp_serverrc – for the OpenERP Server
  • ~/.openerp_serverrc – if running an OpenERP Server inside Eclipse from your own userid
  • /usr/lib/python2.4/site-packages/openerp-server/tools/config.py – for default values if no config file

OpenERP 6 configuration files on Ubuntu 10.10

  • /etc/openerp-web.cfg
  • /etc/init.d/openerp-web
  • /etc/init.d/openerp-server
  • ~openerp/.openerp_serverrc – for the OpenERP Server
  • ~/.openerp_serverrc – if running an OpenERP Server inside Eclipse from your own userid
  • /usr/local/lib/python2.6/dist-packages/openerp-server/tools/config.py – for default values if no config file

OpenERP configuration files on Windows

  • C:\Program Files (x86)\OpenERP AllInOne\Server\openerp-server.conf
  • C:\Users\<Your login>\.openerprc

Postgres configuration files on Centos 5.5

  • /var/lib/pgsql/data/postgresql.conf
  • /var/lib/pgsql/data/pg_hba.conf

Postgres configuration files on Ubuntu 10.10

  • /etc/postgresql/8.4/main/pg_hba.conf
  • /etc/postgresql/8.4/main/postgresql.conf

Postgres configuration files on Windows

  • C:\Program Files (x86)\OpenERP AllInOne\PostgreSQL\data\postgresql.conf
  • C:\Program Files (x86)\OpenERP AllInOne\PostgreSQL\data\pg_hba.conf
  • C:\Program Files (x86)\OpenERP AllInOne\PostgreSQL\data\pg_indent.conf
Posted in OpenERP | Leave a comment

Where are the Log Files for OpenERP?

This is a quick reference for finding OpenERP’s log files.

OpenERP Server logging

Server Log files on Centos 5.5

  • /var/log/openerp-web
  • /var/log/messages (if –syslog option is used to start the openerp server – see /etc/init.d/openerp-server)
  • /var/log/openerp-server (if that is where you pointed your log file to in /etc/init.d/openerp-server)
  • ~openerp/.bzr.log

Client Log files

For the GTK Client on Windows 7:

  • C:\Users\<Your login>\openerp-client.log

Postgres Logging on Centos 5.5

  • /var/lib/pgsql/pgstartup.log (see PGLOG in /etc/init.d/postgresql)
  • /var/lib/pgsql/data/pg_log/postgresql-*.log (see /var/lib/pgsql/data/postgresql.conf)
  • C:\Program Files (x86)\OpenERP AllInOne\PostgreSQL\data\pg_log

Postgres Logging on Ubuntu 10.10

  • /var/log/postgresql/postgresql-8.4-main.log
Posted in OpenERP | Leave a comment

How to recover email after deleted Windows Live Mail account

This post has been moved here.

Posted in Uncategorized | 92 Comments