XLS Reporting in OpenERP

Update:

I have added my code which you can find here,

http://www.4shared.com/archive/XbokLlzO/reporting_latesttar.html

Extract it and read the help.txt file for further info. Good Luck !

What is it ?
I was looking for a native XLS report from OpenERP, which I could not find out. Instead of writing a new extension,

I thought of extending the existing Report engine. I completed the basic version of it.

How to get XLS report ?
You can go to Administration -> Low Level Objects -> Actions -> Report XML and choose a report, then change its type to XLS.

Now try accessing the report as you would do normally. It will through you XLS report.

This extension may not be stable yet, but can be used in development version.

Features:

  • No need to write new reports, It will just work with existing RML reports.
  • It can handle maximum of two levels of nested table in RML.
  • No external dependency except python-xlwt module.

How it Works ?

The new modified code adds a new type called xls and additional functions. When a report is invoked and the type is XLS, it will invoke rml2xls module, which will take care of converting the rml to xls and emit it. The rml2xls, depends on rml2html. The output html generated by rml2html is passed to a custom HTML parser. The HTML parser parses the necessary tags and writes into XLS file.

Where to Download ?

Once testing from our side gets over, I will share it with you.

Ubuntu 10.10 WiFi Problem

When I installed Ubuntu 10.10 ( maverick ) in my Compaq Laptop, everything was perfect except WiFi.

The never detected the Wireless network, even I could not turn the WiFi button on.

I found the problem to be on rfkill keeps blocking the wireless.

Solution:

1) $sudo rm /dev/rfkill

2) Reboot the system

3) $sudo rfkill unblock all ( try to see the output of ‘sudo rfkill list’ to see if it is switched on )

Now you should be able to connect to your wireless network 🙂

OpenERP XML-RPC Java

Introduction

OpenERP’s communication normally happens in two modes

  • Net-RPC
  • XML-RPC

where, net-rpc is considered to be fast for python based applications.
I will discuss here about the xml-rpc calls from Java.
If you want to see all the xml-rpc calls made from GTK client,
start the client with,

./openerp-client.py -l debug_rpc

Java and XML-RPC:

I chose to use Java examples here with apache-xmlrpc-3.1.3 package.

The actual xml-rpc call made for reading Purchase Order is,

1) Setting up things:


XmlRpcClient xmlrpcLogin = new XmlRpcClient();
XmlRpcClientConfigImpl xmlrpcConfigLogin = new XmlRpcClientConfigImpl();
xmlrpcConfigLogin.setEnabledForExtensions(true);
xmlrpcConfigLogin.setEnabledForExceptions(true);
xmlrpcConfigLogin.setServerURL(new URL(“http”,host,port,”/xmlrpc/common”));
xmlrpcLogin.setConfig(xmlrpcConfigLogin);



host and port are self explanatory. Normally, XML-RPC port is 8069.

2) Login to the system:


Vector params = new Vector();

params.addElement(tinydb);//database
params.addElement(login);//user id
params.addElement(password);//pwd
Object id = xmlrpcLogin.execute(“login”, params);


3) Find all the Purchase Order which are in ‘draft’ state:

The actual call made from GTK client looks like this,

rpc.request:(‘execute’, ‘v14’, 1, ‘admin’, (‘purchase.order’, ‘search’, [(‘state’, ‘=’, ‘draft’)], 0.0, 80.0, 0)),

In java, i could write it as,


XmlRpcClientConfigImpl rpc = new XmlRpcClientConfigImpl();
rpc.setEnabledForExtensions(true);
rpc.setEnabledForExceptions(true);
rpc.setServerURL(new URL(“http”,host,port,”/xmlrpc/object”));
xmlrpcLogin.setConfig(rpc);

Object r[]=new Object[6];
r[0]=tinydb;
r[1]=(Integer)id;
r[2]=password;
r[3]=”purchase.order”;
r[4]=”search”;

Object names[]=new Object[3];


Get the PO in state draft,


names[0]=”state”;
names[1]=”=”;
names[2] = “draft”;

Vector param2 = new Vector();
param2.addElement(names);
r[5]=param2;
Object po_ids;
po_ids=xmlrpcLogin.execute(“execute”, r);
Object[] d = (Object[]) po_ids;

Integer i=0;

for(i=0; i<d.length; i++)
System.out.println((Integer)d[i]);


The last loop will print the purchase order ids.

4) Confirm the Purchase Order:

Now, let me just confirm the first purchase order,

The actual python call made would be,
rpc.request:('exec_workflow', 'energy', 1, 'admin', (u'purchase.order', 'purchase_confirm', 4))

and we could write in Java as,


Object r2[]=new Object[7];
r2[0]=tinydb;
r2[1]=(Integer)id;
r2[2]=password;
r2[3]="purchase.order";
r2[4] = "purchase_confirm";
r2[5] = d[0];
Object po_data;
po_data=xmlrpcLogin.execute("exec_workflow", r2);


The exec_workflow, as the name implies, triggers workflow.

Some better java programmer can write simple code for the same purpose 🙂

This post is made from Gedit Editor

First post from Gedit

Introduction

I have integrated gedit, my favorite editor and wordpress blog.

You can refer,

http://www.blackbirdblog.it/programmazione/progetti/28#english

More to follow


I will update with more details soon 🙂

OpenERP-Apache-SSL

OpenERP-Apache with SSL:


I am writing here, how I configured openerp-apache for SSL support in Ubuntu 10.04

LTS.I believe, this could hold good for most debian based systems.

Installing openerp server and client:

You can read the official document in,

http://doc.openerp.com/install/linux/index.html

Installing apache and enabling supporting modules:

$ sudo apt-get install apache2

$ sudo a2enmod ssl

$ sudo a2ensite default-ssl

$ sudo /etc/init.d/apache2 restart

$ sudo a2enmod proxy

$ sudo a2enmod proxy_http

$ sudo a2enmod proxy_connect

$ sudo a2enmod proxy_ftp

$ sudo a2enmod headers

$ sudo /etc/init.d/apache2 restart

Generating keys and certificates:

Now you should see the default certificate and key files,
/etc/ssl/certs/ssl-cert-snakeoil.pem

/etc/ssl/private/ssl-cert-snakeoil.key
You may use openssl to generate your own certificates.

You can read more in,

https://help.ubuntu.com/8.04/serverguide/C/certificates-and-security.html

Web server configurations:

Edit /etc/apache2/ports.conf and add a new line,
Listen 443
Make sure you don’t have two entries for same port.
If you have static IP and domain name, edit the file /etc/hosts and add a new line,
127.0.0.1       localhost

127.0.1.1       selvam-laptop

MY_STATIC_IP    MY_DOMAIN

Proxy setting:

We will use reverse proxy here.

You can read more about reverse proxy in,

http://en.wikipedia.org/wiki/Reverse_proxy

To setup Reverse proxy,
Edit /etc/apache2/sites-available/default-ssl and add these lines in the last part.
<VirtualHost 127.0.0.1:443>

<Proxy *>

AddDefaultCharset off

Order deny,allow

Allow from all

</Proxy>

ProxyRequests Off
ProxyPass   /   http://127.0.0.1:8080/

ProxyPassReverse /   http://127.0.0.1:8080/

RequestHeader set “X-Forwarded-Proto” “https”
# Fix IE problem (http error 408/409)

SetEnv proxy-nokeepalive 1

</VirtualHost>

The same file should already contain the lines,

SSLEngine on

SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem

SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

Postgres permissions:

Add postgres user to the ssl-cert group by,

usermod -aG ssl-cert postgres

Change the permission of key file like below,

chmod -R 650 /etc/ssl/private/

It should look like,
drw-r-x— 2 root ssl-cert  4096 2010-10-26 00:14 private

Otherwise you may face error “Can not read server.key file, permission denied”

on postgres start.

To make sure the key file is accessible, login as postgres user and use,

$cat /etc/ssl/private/ssl-cert-snakeoil.key

The symbolic links from postgres will look like,

$  ls -l /var/lib/postgresql/8.4/main/s*

lrwxrwxrwx  1 postgres ssl-cert   36 2010-10-25 19:55 server.crt -> /etc/ssl/certs/ssl-cert-snakeoil.pem
lrwxrwxrwx  1 postgres ssl-cert   38 2010-10-25 19:55 server.key -> /etc/ssl/private/ssl-cert-snakeoil.key

Openerp-Web Configuration:

update the openerp-web.cfg with,

server.socket_host = “127.0.0.1”

tools.proxy.on = True

base_url_filter.on=True

base_url_filter.use_x_forwarded_host = False

base_url_filter.base_url = “https://127.0.0.1&#8221;

tools.csrf.on = False

Starting Server:

$ sudo /etc/init.d/apache2 restart

$ sudo /etc/init.d/postgresql-8.4 force-reload

Restart the openerp-web.

Restart the openerp-server as,

openerp-server –secure –cert-file=/etc/ssl/certs/ssl-cert-snakeoil.pem –pkey-file=/etc/ssl/private/ssl-cert-snakeoil.key

You can use -s to save configuration to ~/.openerp_serverrc

Now, you should be able to access,

https://127.0.0.1/ as well as http://127.0.0.1:8080.

Troubleshooting:

If you face any errors in accessing the final https://127.0.0.1/ site,

You could see the output of error log to figure out the issue,

$tail -f /var/log/apache2/error.log

References:
http://tipstricks.itmatrix.eu/?p=497
http://doc.openerp.com/install/linux/web/index.html
http://www.openerp.com/forum/topic20712.html

OpenERP with GIT

What is OpenERP?

A  powerful, flexible python based OpenSource ERP system.

What is GIT ?

A distributed SCM written by Linus Torvalds . You can read more on this,
http://git-scm.com/

Why OpenERP’s Project Management?

OpenERP’s project management has a very nice set of features like tasks, task delegation,multi level nesting of projects,  linked to tasks, analytic account linked to project which augments you to clearly track the project and costs involved  and so on.

You can read more about OpenERP’s project management at,

http://doc.openerp.com/book/4/4_13_Projects/4_13_Projects_management.html

Why is the OpenERP – GIT integration?

Only thing missing, which I noticed was its SCM (Source Code Management) integration, which could be useful for software firms. Then I took it as my Sunday project aiming for 5.X version of OpenERP and here i am with it.

Basic Features of the module:It allows you to do,

  • Associate one or more git repositories to a Project
  • Tasks can be updated based on the commit message used.
  • Task work time can also be updated from the commit message, so that users do not have to login to the system.
  • From task, you can see all the associated revisions made by the members.
  • From the Project, you can see all the revisions made by the project members.

Detailed guide:

Installation:

Install the module project_git which requires python-dulwich module.

You can install it as, apt-get install python-dulwich, in debian based system.

Configuration:

When you install the module a cron will be set-up which by default run for every 5 minutes.

You can change this timing by searching for the name “Git Repo” under

Administration -> Configuration -> Scheduler -> scheduled actions.

Now,

Go to your project and switch to the Git Repositories tab.

Here you can add multiple local repositories.

For eg: /srv/test_repo

Git Repository

Sample Git Repo

and you can use “Test Repo” button in the form, to test if the git directory really exists.

Thats it, we are ready to go !

Reactions:

Once you install this module it will add an auto increment number to the Project task.

This needs to be used for referring tasks from git commit messages.

A new action “All Revisions” will be added to Tasks and Projects.

Commit messages:

It supports three attributes as of now,

1) #refs
2) #time
3) #user

For eg:
a) git commit -m “Initial commit #refs T0001”:

It will update your task identified by the number T0001 with this revision.

b) git commit -m “Initial commit #refs T0001 #time 3 #user selvam”:

It will update your task identified by the number T0001 with this revision and also update the Task Work field of the particular task with 3 hours of work done by the user selvam, which is the login name for the user.

c) git commit -m “Initial commit #refs T0001,T0002,T0003 #time 3,5,6 #user selvam”:

Similar to the last one except that this update the three tasks with respective timings.

Warning: If the you are giving 3 task references and 2 timings, then time updating will not happen.

Miscellaneous:

1) Commit message #user, must be associated with an employee.

2) Project needs to be associated with an Analytic account.

Viewing Revisions:

In each task, there will be a Revision tab which will list all the revisions with respect to that task.
If you want to view them in new window, choose “All Revisions” from the actions.
From a Project choose “All Revisions” from the actions, for viewing all the revision with respect to the project.

Revisions

Revisions

Task Update:

Commit will update the task work, with the commit message and user referred in the commit message.

Task and Time spent

Task and Time spent

You can also see the related revisions in task,

Task Revision

Task Revision

Where to Download ?

If you have a launchpad account, from  your addons directory you can do,

bzr branch lp:~e-ndicusteam/openerpgit/project_git

Roadmap:

  • Timing problem with git.
  • Regex needs to be removed from git message
  • Wrong commit needs to marked as exception.
  • Time based update need to be based on a switch, that can be disabled.
  • Branch based revisions, so that you can filter based on Branches in a particular repository.
  • Tree structure navigation for git repositories.
  • Integration with Project issue.

OpenERP

Coming soon,
My OpenERP experiences…

Previous Older Entries Next Newer Entries

%d bloggers like this: