Friday, April 23, 2010

OpenERP - running the Trunk - YAML dependency missing

So I got the  latest tunk from Bazaar

First run :

chanon@batman:~/openerp-TRUNK/openerp/server/bin$ ./openerp-server.py
Traceback (most recent call last):
  File "./openerp-server.py", line 54, in
    import netsvc
  File "/home/chanon/openerp-TRUNK/openerp/server/bin/netsvc.py", line 273, in
    import tools
  File "/home/chanon/openerp-TRUNK/openerp/server/bin/tools/__init__.py", line 26, in
    from convert import *
  File "/home/chanon/openerp-TRUNK/openerp/server/bin/tools/convert.py", line 40, in
    from yaml_import import convert_yaml_import
  File "/home/chanon/openerp-TRUNK/openerp/server/bin/tools/yaml_import.py", line 10, in
    import yaml_tag
  File "/home/chanon/openerp-TRUNK/openerp/server/bin/tools/yaml_tag.py", line 1, in
    import yaml
ImportError: No module named yaml



Solution : http://pyyaml.org/wiki/PyYAML (find the PyYAML package you need, run the sudo python setup.py install command).

Second

[2010-04-23 13:10:34,751] INFO:objects:initialising distributed objects services
Traceback (most recent call last):
  File "./openerp-server.py", line 91, in
    import report
  File "/home/chanon/openerp-TRUNK/openerp/server/bin/report/__init__.py", line 22, in
    import interface
  File "/home/chanon/openerp-TRUNK/openerp/server/bin/report/interface.py", line 32, in
    import render
  File "/home/chanon/openerp-TRUNK/openerp/server/bin/report/render/__init__.py", line 23, in
    from rml import rml, rml2html, rml2txt, odt2odt , html2html, makohtml2html
  File "/home/chanon/openerp-TRUNK/openerp/server/bin/report/render/rml.py", line 28, in
    import makohtml2html as makohtml
  File "/home/chanon/openerp-TRUNK/openerp/server/bin/report/render/makohtml2html/__init__.py", line 22, in
    from makohtml2html import parseNode
  File "/home/chanon/openerp-TRUNK/openerp/server/bin/report/render/makohtml2html/makohtml2html.py", line 21, in
    import mako
ImportError: No module named mako


So one more Template engine for today, solution :
easy_install Mako


And that's it. More about 6.0 later...

Thursday, April 22, 2010

Changing the invoice layout in OpenERP

edit the invoice.sxw in ../addons/account/report

python ../../base_report_designer/wizard/tiny_sxw2rml/tiny_sxw2rml.py invoice.sxw

if the result is something else than an error.. you can save the new invoice.rml.

Wednesday, April 14, 2010

James Gosling left java

As many people know, James Gosling, the father of Java left Oracle. It seems it last speaches describeb the Java Community Process as a Nightmare.

http://www.theserverside.com/discussions/thread.tss?thread_id=59733.

I worked in standardization comitte, years ago. Technical-politics are not fun. In fact it is a general issue with getting people from different horizon to work together for the common interrest.

One remark, JEE6 really rocks and is probably much more agile than many other things. The ability to hot deploy and keep session state in Glassfish is very impressive and largely superior to anything - including the OpenERP Python module load stuff (at least on the debug cycle/ reload cycle).

Monday, April 12, 2010

Open ERP Guidelines

Some guidelines about Open ERP contribution...

http://doc.openerp.com/contribute/15_guidelines/

Friday, April 09, 2010

VirtualBox / Ubuntu 9.10 getting resolution higher than 800x600

In order to evaluate one more extension for OpenERP (medical), we moved to virtualBox and Ubuntu 9.10.

Windows (7 but also XP) complains about the driver signature but we ignored it and this just worked. However the screen remains stretched at 800x600 resolution. Moving to full screen changed nothing.

Similar experience with Vmware got me to the install of the addons inside the new virtual host. But nothing changed inspite of a few reboots...

So the rest is based on various post on the web and a bit of tweaking on my side...

1) There is a VirtualBox command line :

C:\Program Files\Sun\VirtualBox>VBoxManage.exe setextradata global GUI/MaxGuestResolution 1600,1200

No change at this stage.

2) Searching on the web... I found a comment suggesting to add a display in the /etc/X11/xorg.conf:

SubSection "Display"
            Depth        24
            Modes        "1024x768"
        EndSubSection

3) But I could not find any xorg.conf !
I and X never made a good couple. 10 years ago I burned a screen playing with frequency settings... A few posts suggested to create and xorg.conf manually. That's the hard way and I am lazy more by caution than by nature...

4) Ubuntu is getting away of xorg.conf !
Here is a post that saved me (could not find the name of the author -- so a lot of thanks if he recognizes these lines)
This command will stop the X : sudo service gdm stop
Now we need to generate the xorg.conf file:  sudo Xorg -configure
This has generated the file in ~/xorg.conf.new.
We need to make the X using it so we have to put this file inside /etc/X11/Example :  ~# sudo mv ~/xorg.conf.new /etc/X11/xorg.conf
After moving this file to the proper location you can start the X again and see what happens: sudo service gdm start

No here is my added value of the day:

5) Control the resolutions available with : xrandr

6) And finally the problem is... 
that because in Ubuntu 9.10 xorg.conf is not there by default it is not adapted... so just re-install the virtual box driver (tip when they are installed on the bottom bar you see a mouse with a green arrow)  and you can see X11 being updated. One more restart and you are in business !

See below for reference and enjoy higher resolution !

fred@fred-desktop:/media/cdrom$ sudo ./VBoxLinuxAdditions-x86.run
[sudo] password for fred:
Verifying archive integrity... All good.
Uncompressing VirtualBox 3.1.6 Guest Additions for Linux........
VirtualBox Guest Additions installer
Removing installed version of VirtualBox Guest Additions...
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module
 ...done.
Building the shared folder support module ...done.
Building the OpenGL support module ...done.
Doing non-kernel setup of the Guest Additions ...done.
You should restart your guest to make sure the new modules are actually used

Installing the Window System drivers
Installing X.Org Server 1.6 modules ...done.
Setting up the Window System to use the Guest Additions ...done.
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.

Wednesday, April 07, 2010

I love you find !

I messed up again with links in my OpenERP addons  directory...

find . -lname \*addons-extra\*  -exec rm  {} \;

I feel better...

Tuesday, April 06, 2010

Spending a minute in copyright metric

Here is for addons

chanon@batman:~/openerp-REG/openerp/addons$ find . -name *.py -exec grep Copyright {} \;  | wc -l
776
chanon@batman:~/openerp-REG/openerp/addons$ find . -name *.py -exec grep Copyright {} \;  | grep Tiny | wc -l
718

And for addons-extra

chanon@batman:~/openerp-REG/openerp/addons-extra$ find . -name *.py -exec grep Copyright {} \;  | wc -l
1789
chanon@batman:~/openerp-REG/openerp/addons-extra$ find . -name *.py -exec grep Copyright {} \;  | grep Tiny | wc -l
1193

So 10% in the first case and 30% in the second one. I will try to elaborate more on these figures.

Back to OpenERP ... programming

So, I just added a wizard for automating membership renewal.

Finding the right company to renew and the right address is a bit tricky with the Open ERP so called ORM.

So the solution is to use the SQL pass-trough alternative: cr.execute.

I did and it works pretty well. On the other side, each of these calls is a short- circuit in the programming model, heritance and ... security checking. Don't take me wrong on this, but let's admit this is a technical insider concern...

So how much does this affect the code base ?

chanon@batman:~/openerp-REG/openerp/addons$ ls -l | wc -l
114
chanon@batman:~/openerp-REG/openerp/addons$ find . -name *.py -exec grep cr.execute {} \; | wc -l
579




So without doing many math, I think a good part of the entire code base is concerned.

I am not jumping on this right away, but I need to dig more...

Monday, April 05, 2010

Extensibility Part II - Hot properties

After my look at the past, let’s go back to day to day operations, I closed a deal a few weeks ago for a real estate web site based on Joomla. We build ‘cheap’ here using one of these little extensions that are  on the Joomla market place: Hot Property (HP).

For each property, HP provides a limited number of fields. Each one is implemented as a column in the real estate properties table. Yet the developer had the idea to make the software extensible, so you can add more fields to your properties descriptions. Surprisingly all these fields go in a separate table…  where you find fields id and values and the id off the real estate property.

Obviously, SQL querying on these is a nightmare... (I exaggerate again, at least we can say things are more complicated and imply joins that are source of performance drops and misunderstanding - e.g when customers attempt to build their own reports).

As you can see, values are stored as text (why the hell have they invented all these data types – may be a precursor of XML). I am putting here the layout of the values table. Another table contains the definition of the extra-fields. Strangely, while we have just a foreign key between the extra fields and the property, HP lets only one field (of a given type) per property.

It is difficult to know why a developer took a path or another. This is not a criticism on HP -It is a very affordable and workable Joomla component. I see anyway, a few reasons…

  1. Very few people like programming the DDL (Data Definition Language). 
  2. Attempting to shield from the database, HP is written with a framework including a primitive (sorry to say) persistence layer. Yet if PHP is dynamic the PHP model is statically linked with MySQL using PHP definitions.  
  3. Finally reflection is something that many programmers do not envisage – among the reason is that again DDL and meta-schema is not that standard… 

All that can be combined in one  DDL+Reflexion+Persistence layer (ORM) is still a problem. Choosing at which moment you decide in your layers to be static is a tough decision…

In the case of HP, extensibility could be much higher since the application is basically a CRUD thing. The gotcha in DB application design is there : when adding processing, logic well you are obliged to statically bind your code (even if you don’t realize it, just a reference in  the code and the magic of dynamic reflection is broken) and the persistent DB model.

I like this subject that much that I am afraid… it will be continued again!