[IMP] unaccent: added an unaccent command-line flag, and a function to test unaccent availability.
bzr revid: vmt@openerp.com-20110722081030-ltxuqknpe1arduw5
This commit is contained in:
parent
f59a0b6025
commit
266cad9a2e
|
@ -118,4 +118,14 @@ def create_categories(cr, categories):
|
|||
categories = categories[1:]
|
||||
return p_id
|
||||
|
||||
def has_unaccent(cr):
|
||||
""" Test if the database has an unaccent function.
|
||||
|
||||
The unaccent is supposed to be provided by the PostgreSQL unaccent contrib
|
||||
module but any similar function will be picked by OpenERP.
|
||||
|
||||
"""
|
||||
cr.execute("SELECT proname FROM pg_proc WHERE proname='unaccent'")
|
||||
return len(cr.fetchall()) > 0
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
import openerp.sql_db
|
||||
import openerp.osv.orm
|
||||
import openerp.modules.db
|
||||
|
||||
|
||||
class Registry(object):
|
||||
|
@ -44,6 +45,10 @@ class Registry(object):
|
|||
self.db_name = db_name
|
||||
self.db = openerp.sql_db.db_connect(db_name)
|
||||
|
||||
cr = self.db.cursor()
|
||||
self.has_unaccent = openerp.modules.db.has_unaccent(cr)
|
||||
cr.close()
|
||||
|
||||
def do_parent_store(self, cr):
|
||||
for o in self._init_parent:
|
||||
self.get(o)._parent_store_compute(cr)
|
||||
|
|
|
@ -250,6 +250,8 @@ class configmanager(object):
|
|||
"osv_memory tables. This is a decimal value expressed in hours, "
|
||||
"and the default is 1 hour.",
|
||||
type="float")
|
||||
group.add_option("--unaccent", dest="unaccent", my_default=False,
|
||||
help="Use the unaccent function provided by the database when available.")
|
||||
parser.add_option_group(group)
|
||||
|
||||
# Copy all optparse options (i.e. MyOption) into self.options.
|
||||
|
|
Loading…
Reference in New Issue