09 Feb 2012

Installing Zoook on Ubuntu – Part IV: Zoook - Parametrize and connect with OpenERP

Escrito por  Thomas

Artículo también disponible en castellano.

The final part of the series of articles dedicated to Zoook. After finalising the installation of Zoook we're going over to its parametrisation and the connection with the OpenERP server.

1. Install OpenERP dependencies

You'll have to install the following modules in OpenERP:

2. Connecting Zoook to the Database

At first create a PostgreSQL database for Zoook. In a development environment you can use the user openerp. This way you don't have to create a new one. In production its recommended to make sure that every user has an exclusive access to the database.

$ sudo -u postgres psql
postgres=# CREATE DATABASE dj_zoook OWNER openerp;
postgres=# \l

The last command shows the existent databases. If everything worked out fine it should show someting like the following:

http://www.domatix.com/images/stories/noticias/2011/list_databases.png

Verify the correct creation of the database.

3. Parametrisation of Zoook

3.1. ~/django-projects/zoook-app/config.py

Edit the file and adjust the parameters of the connection to OpenERP. You'll have to configure all passages. The following ones are especially important for the interconnection with the OpenERP server and error detection:

  • LANGUAGES

    Defines the languages of your web shop. They have to be the same as in OpenERP.

    #Edit your languages
    LANGUAGE_CODE = 'es'
    LANGUAGES = (
        ('es', ugettext('Spanish')),
        ('en', ugettext('English')),
    )
    DEFAULT_LANGUAGE = 1
    LOCALE_URI = True
    
  • OERP_SALE

    Indicates which OpenERP shop should be used in Zoook (just for the case that you have several shops).

    OERP_SALE = 1 #Sale Shop. All price, orders, ... use this Sale Shop ID.
    
  • LOGS

    Defines the path to Zoooks logging files.

    LOGFILE = '/home/roberto/django-projects/zoook-app/log/sync.log' #path sync log
    LOGSALE = '/home/roberto/django-projects/zoook-app/log/sale.log' #path sale log
    
  • DATABASES

    Defines where and how Zoook finds its database.

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
            'NAME': 'dj_zoook',     # Or path to database file if using sqlite3.
            'USER': 'openerp',      # Not used with sqlite3.
            'PASSWORD': 'openerp',  # Not used with sqlite3.
            'HOST': 'localhost',    # Set to empty string for localhost. Not used with sqlite3.
            'PORT': '5432',         # Set to empty string for default. Not used with sqlite3.
        }
    }
    
  • OERP_CONF

    Defines the connection to the XML-RPC service of OpenERP.

    OERP_CONF = {
        'username':'admin',
        'password':'openerp',
        'dbname':'openerp',
        'protocol':'xmlrpc', #xmlrpc
        'uri':'http://localhost', #xmlrpc
        'port':8069, #xmlrpc
    # 'protocol':'pyro', #pyro
    # 'uri':'localhost', #pyro
    # 'port':8071, #pyro
    }
    

3.2. ~/django-projects/zoook-app/sync/config_path.py

Contains the routes to Zoook so that the SSH synchronisation process can find the needed files.

djpath = '/home/roberto/django-projects/zoook-app'

3.3. ~/django-projects/zoook-app/settings.py

Edit this file to assign a new unique password to Zoook. I'd recommend to use a password generator such as safepasswd.com.

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'YOUR_PASSWORD_GOES_HERE'

3.4. Create Zoooks database tables

  • Generate the data base structure
    $ cd ~/django-projects/zoook-app
    $ python manage.py syncdb
    

    The script will ask if you want to create a new super-user. Affirm and pass it the needed data for the account you'll later want to administer Zoook with.

    http://www.domatix.com/images/stories/noticias/2011/syncdb_superuser3.png

    Create a superuser for Django.

3.5. ~/django-projects/zoook-app/configuration.py

Execute the configuration assistant and give it further information needed by Django.

  • Execute configuration.py
    $ cd ~/django-projects/zoook-app
    $ ./configuration.py
    

    The output should look like this:

    http://www.domatix.com/images/stories/noticias/2011/asistente_configuration.png

    Configuration of Django.

3.6. Adjust file permissions

  • Change the permissions in the sync directory
    $ cd ~/django-projects/zoook-app/
    $ sudo chown -R roberto:www-data *
    $ sudo chmod 775 -R sync
    

3.7. Testing Zoook

  • Run the server
    $ cd ~/django-projects/zoook-app/
    $ python manage.py runserver
    

    this should show something like:

    http://www.domatix.com/images/stories/noticias/2011/server_django_post.png

    Successfully initiated Django server.

    Open your browser and open up the direction of the server (http://127.0.0.1:8000/). Zoook should load the first time and you should end up with a site like this:

    http://www.domatix.com/images/stories/noticias/2011/server_zoook_test.png

    Start page of Zoook.

    Access the administration area with the super user credentials created beforehand:

    http://www.domatix.com/images/stories/noticias/2011/zoook_administration.png

    Zooks administration page.

4. Connecting Zoook with OpenERP

A SSH server is required on the machine where Zoook is installed:

$ sudo apt-get install openssh-server

The next step is to configure poweremail to create a template for orders. This article won't cover the further details of this step. You can get that information here.

Now, open up OpenERP and configure the shop for the connection with Zoook. Open

Sales => Configuration => Sales => Shop

Choose the shop you're going to use with Zoook, edit it and check the box next to OpenERP e-Sale in the upper right. As an outcome of this should appear a new configuration tab for Zoook.

http://www.domatix.com/images/stories/noticias/2011/openerp_config_tienda001.png

Mark a shop fort exportation.

http://www.domatix.com/images/stories/noticias/2011/openerp_config_tienda002.png

Mark all products for exportation.

http://www.domatix.com/images/stories/noticias/2011/openerp_config_tienda007.png

Configure the SSH connection.

When doing the test of the connection it should pop up a message, saying that it is configured properly.

5. Export test products

Now, we'll only have to add some test categories and products. The only thing noteworthy at this point is that in order to export a product to the web you have to check “Export to online shop?”. Once this is checked you'll see a new tab with the name “e-Sale” where you can parametrise the options of the product of the web shop.

http://www.domatix.com/images/stories/noticias/2011/openerp_config_product.png

Configuring e-Sale options on a product.

After the creation of products you'll have to go back to the configuration of the shop to export products, categories, images etc. After doing a refresh of the page of Zoook you should be able to see the introduced data:

http://www.domatix.com/images/stories/noticias/2011/zoook_category_view.png

Successfully exported category in Zoook.

http://www.domatix.com/images/stories/noticias/2011/zoook_product_view.png

Successfully exported product in Zoook.

Domatix Technologies, S.L.U. - C/Espinosa 8 - 46008 - Valencia - Telf.: 963 230 962
Delegación Murcia - C/Juan de Juanes 4 - 30740 - San Pedro del Pinatar - Murcia