Browse Source

Migrated base_search_fuzzy to v9

pull/1290/head
darshan-serpent 8 years ago
committed by Jairo Llopis
parent
commit
a55e4a1e5f
  1. 2
      base_search_fuzzy/README.rst
  2. 2
      base_search_fuzzy/__init__.py
  3. 10
      base_search_fuzzy/__openerp__.py
  4. 2
      base_search_fuzzy/models/__init__.py
  5. 11
      base_search_fuzzy/models/ir_model.py
  6. 2
      base_search_fuzzy/models/trgm_index.py
  7. 2
      base_search_fuzzy/tests/__init__.py
  8. 2
      base_search_fuzzy/tests/test_query_generation.py

2
base_search_fuzzy/README.rst

@ -87,6 +87,8 @@ Contributors
------------
* Christoph Giesel <https://github.com/christophlsa>
* Jordi Ballester <jordi.ballester@eficent.com>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
Maintainer
----------

2
base_search_fuzzy/__init__.py

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models

10
base_search_fuzzy/__openerp__.py

@ -1,17 +1,19 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': "Fuzzy Search",
'summary': "Fuzzy search with the PostgreSQL trigram extension",
'category': 'Uncategorized',
'version': '8.0.1.0.0',
'version': '9.0.1.0.0',
'website': 'https://odoo-community.org/',
'author': 'bloopark systems GmbH & Co. KG, '
'Eficent Business and IT Consulting Services S.L., '
'Serpent Consulting Services Pvt. Ltd., '
'Odoo Community Association (OCA)',
'license': 'AGPL-3',
'depends': [
'base',
],
'depends': ['base'],
'data': [
'views/trgm_index.xml',
'security/ir.model.access.csv',

2
base_search_fuzzy/models/__init__.py

@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import ir_model
from . import trgm_index

11
base_search_fuzzy/models/ir_model.py

@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
from openerp import models
from openerp import models, api
from openerp.osv import expression
@ -21,9 +23,9 @@ def patch_leaf_trgm(method):
params = []
if left in model._columns:
format = model._columns[left]._symbol_set[0]
formats = model._columns[left]._symbol_set[0]
column = '%s.%s' % (table_alias, expression._quote(left))
query = '(%s %s %s)' % (column, sql_operator, format)
query = '(%s %s %s)' % (column, sql_operator, formats)
elif left in expression.MAGIC_COLUMNS:
query = "(%s.\"%s\" %s %%s)" % (
table_alias, left, sql_operator)
@ -49,6 +51,8 @@ def patch_leaf_trgm(method):
def patch_generate_order_by(method):
@api.model
def decorate_generate_order_by(self, order_spec, query):
if order_spec and order_spec.startswith('similarity('):
return ' ORDER BY ' + order_spec
@ -78,5 +82,4 @@ class IrModel(models.Model):
'__decorated__'):
models.BaseModel._generate_order_by = patch_generate_order_by(
models.BaseModel._generate_order_by)
return super(IrModel, self)._register_hook(cr)

2
base_search_fuzzy/models/trgm_index.py

@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging

2
base_search_fuzzy/tests/__init__.py

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import test_query_generation

2
base_search_fuzzy/tests/test_query_generation.py

@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp.osv import expression
from openerp.tests.common import TransactionCase, at_install, post_install

Loading…
Cancel
Save