Home > Programming, Windows > Increasing price accuracy from 2 to 3 in OpenERP

Increasing price accuracy from 2 to 3 in OpenERP

Last week I was faced with the dilemma of increasing the price accuracy from 2 to 3 in OpenERP for a client who uses OpenERP server 5.0.6

OpenERP server has a configuration for the price accuracy in its configuration file, but as of 5.0.6 it seems to be to effective.

Changing the value in the config from 2 to 3 had no effect. On Googling around it seems to be a bug that may be fixed in the upcoming 6.0.0 release.

However the price accuracy config option can be passed directly when starting the server. This option works for both Linux and Windows. However windows has a major draw back that the windows service that creates the openerp-server process does not allow passing additional parameters. Though u can start the openerp server manually in windows with the parameter, when it comes to having the server started by the service, it won’t work. Thus the need to have to pull source code of the openerp service from launchpad, modify it to pass price accuracy parameter, and recompile it.

The Price accuracy hack steps:-

1. Backup the schema

pg_dump.exe -h localhost -U postgres -f c:\Users\admin\Desktop\Pool2\schema.sql -s databaseName

2. Backup the data

pg_dump -h localhost -U postgres -a -F c -f c:\users\admin\desktop\pool2\data.sql databaseName

3. Alter the schema

Replace numeric(16,2) with numeric(16,3)

4. Drop the Database

Use pgadmin to drop the database.

5. Create the database

Use pgadmin to create the database.

6. Restore the schema

psql -h localhost -U postgres -f c:\Users\admin\Desktop\Pool2\schema.sql -d pool2

7. Restore the data

pg_restore -h localhost -U postgres -d pool2 –disable-triggers -a c:\Users\admin\Desktop\pool2\data.sql

Steps to fix the service to start with price accuracy 3

To perform these steps you will require to have python2.5 installed plus the py2exe python package.
First uninstall the OpenERPServerService service by executing OpenERPServerService.exe -remove

Files required:-
OpenERPServerService.py
setup.py

1. Copy OpenERPServerService.py and setup.py to the service folder e.g to C:\OpenERP AllInOne\Server\service
NB. I did modify OpenERPServerService.py to pass price_accuracy=3.

self.terpprocess = subprocess.Popen([server_path, “–price_accuracy=3”], cwd=server_dir, creationflags=win32process.CREATE_NO_WINDOW)

2. Start the command prompt as an administrator.

3. Change to the service directory. e.g to C:\OpenERP AllInOne\Server\service

4. Execute c:\python25\python.exe setup.py py2exe

5. Incase errors occur regarding inability to load resource please perform 4 once again.

6. If 5 is successfulll, folders build and dist would have been created. Change to the dist folder and copy the OpenERPServerService.exe to the directory before it.

7. In the dist folder, Open the library.zip and copy out the compiled python file OpenERPServerService.pyc and replace the OpenERPServerService.pyc of the library.zip in the service folder.

8. Install the service by executing OpenERPServerService.exe -install

Voila we are there. U can now start openerp service with an upgraded database and service with price accuracy 3

Categories: Programming, Windows Tags: , ,
  1. Eric Bouchard
    October 13, 2010 at 7:16 am

    Thanks been trying to change this for a while, worked in 15 minutes!

  1. No trackbacks yet.

Leave a reply to Eric Bouchard Cancel reply