Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

9

How to search without accented characters?

By
Ahmet Altinisik
on 2/13/13, 5:34 AM 9,425 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).

14

Guewen Baconnier - Software Developer, Camptocamp

--Guewen Baconnier - Software Developer, Camptocamp--
2658
| 6 7 8
Lausanne, Switzerland
--Guewen Baconnier - Software Developer, Camptocamp--

Guewen works at Camptocamp as an Odoo developer since 2010. He is the lead developer of the Odoo Connector framework and the Magento Connector. He is a delegate member of the OCA, a committer and an active contributor to the OCA projects.

 

Guewen Baconnier - Software Developer, Camptocamp
On 2/13/13, 5:58 AM

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.

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.

Altınkaya Elektronik Cihaz Kutuları imalat Ticaret ltd sti, Ahmet Altinisik
on 2/13/13, 7:37 AM

I edited my answer with the installation instructions for postgresql 9.1

Camptocamp SA, Guewen Baconnier - Software Developer, Camptocamp
on 2/13/13, 8:11 AM

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\"";

Altınkaya Elektronik Cihaz Kutuları imalat Ticaret ltd sti, Ahmet Altinisik
on 2/17/13, 1:55 PM

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.

Jairo Llopis
on 1/24/14, 4:40 AM

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?

Gilles Lehoux
on 3/22/14, 7:00 PM
0

Ahmet Altinisik

--Ahmet Altinisik--
2137
| 8 7 10
ANKARA, Turkey
--Ahmet Altinisik--

http://www.altinkaya.eu

Ahmet Altinisik
On 2/13/13, 7:50 AM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 2/13/13, 5:34 AM
Seen: 9425 times
Last updated: 3/16/15, 8:10 AM