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).
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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).
You have some details about that in server/openerp/osv/expression.py
.
Basically you'll need to:
unaccent.sql
--unaccent
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\"";
unaccent
on Posgresql 9.0The 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
You can check if unaccent is working doing:
psql <database> -c "select unaccent('hélène')"
It should display helene
.
Start the server with the option --unaccent
/path/to/openerp-server.py --unaccent
Or add the option
unaccent = True
in the OpenERP configuration file.
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
superb let me try and get back
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.
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