This question has been flagged
2 Replies
36277 Views

I would like to know how can we enable to search without accented characters in OpenERP.

For instance: searching for café would return results containing café (with accent) and cafe (without accent).

Avatar
Discard
Best Answer

You have some details about that in server/openerp/osv/expression.py.

Basically you'll need to:

  1. Install the PostgreSQL contrib unaccent.sql
  2. Launch your OpenERP server with the option --unaccent

Install unaccent on Postgresql 9.1+

The unaccent contrib comes with Postgresql contribs. On Debian / Ubuntu, in order to have the contribs, you need to install postgresql-contrib:

sudo apt-get install postgresql-contrib-9.1

You should use the new CREATE EXTENSION command to install unaccent:

psql <database> -c "CREATE EXTENSION \"unaccent\"";

Install unaccent on Posgresql 9.0

The unaccent contrib comes with Postgresql contribs. On Debian / Ubuntu, in order to have the contribs, you need to install postgresql-contrib:

sudo apt-get install postgresql-contrib-9.0

The unaccent contrib has to be enabled on the database (below, <database> is the database where you want to enable the searches with accents, check the postgresql version in the path):

psql <database> -f /usr/share/postgresql/9.0/contrib/unaccent.sql

Check if it works

You can check if unaccent is working doing:

psql <database> -c "select unaccent('hélène')"

It should display helene.

Start the server

Start the server with the option --unaccent

/path/to/openerp-server.py --unaccent

Or add the option

unaccent = True

in the OpenERP configuration file.

Avatar
Discard
Author

thank you for the nice and clear answer. I just got stuck in the enabling unaccent.sql to the database. I am running ubuntu 12.04 with postgresql 9.1 installed postgresql-contrib but cannot find the unaccent.sql in my system.

I edited my answer with the installation instructions for postgresql 9.1

Author

superb let me try and get back

Author

Works nicely, Thanks again. Note that psql <database> -c "CREATE EXTENSION \"unaccent\""; command should run as a postgress admin user like: sudo -u postgres psql <database> -c "CREATE EXTENSION \"unaccent\"";

Instead of adding --unaccent to the server startup command, you can add unaccent = True to /etc/openerp/openerp-server.conf and just do a sudo service openerp restart.

I used: sudo -u postgres psql <database> -c "CREATE EXTENSION \"unaccent\""; but got ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/unaccent.control": No such file or directory ERROR:: command not found What is my error? Missing step?

Thank you so much, that worked like Charm.

Author Best Answer

thank you for the nice and clear answer. I just got stuck in the enabling unaccent.sql to the database. I am running ubuntu 12.04 with postgresql 9.1 installed postgresql-contrib but cannot find the unaccent.sql in my system.

sudo apt-get install postgresql-contrib

but there is no unaccent.sql when I do a locate search two similar files show up

locate unaccent

/usr/share/postgresql/9.1/extension/unaccent--1.0.sql
/usr/share/postgresql/9.1/extension/unaccent--unpackaged--1.0.sql

there are two different unaccent sql files which file should I use

/usr/share/postgresql/9.1/extension/unaccent--1.0.sql

or

/usr/share/postgresql/9.1/extension/unaccent--unpackaged--1.0.sql

Avatar
Discard