diff --git a/base_search_fuzzy/README.rst b/base_search_fuzzy/README.rst index 1ee718a49..03a90789d 100644 --- a/base_search_fuzzy/README.rst +++ b/base_search_fuzzy/README.rst @@ -87,6 +87,8 @@ Contributors ------------ * Christoph Giesel +* Jordi Ballester +* Serpent Consulting Services Pvt. Ltd. Maintainer ---------- diff --git a/base_search_fuzzy/__init__.py b/base_search_fuzzy/__init__.py index 66efa2ce7..4704284df 100644 --- a/base_search_fuzzy/__init__.py +++ b/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 diff --git a/base_search_fuzzy/__openerp__.py b/base_search_fuzzy/__openerp__.py index e3ef3d024..85db109ef 100644 --- a/base_search_fuzzy/__openerp__.py +++ b/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', diff --git a/base_search_fuzzy/models/__init__.py b/base_search_fuzzy/models/__init__.py index e06aa4361..c64b6641d 100644 --- a/base_search_fuzzy/models/__init__.py +++ b/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 diff --git a/base_search_fuzzy/models/ir_model.py b/base_search_fuzzy/models/ir_model.py index 8be90b8e3..a56cb32ea 100644 --- a/base_search_fuzzy/models/ir_model.py +++ b/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) diff --git a/base_search_fuzzy/models/trgm_index.py b/base_search_fuzzy/models/trgm_index.py index d4ecc1025..4c99c1656 100644 --- a/base_search_fuzzy/models/trgm_index.py +++ b/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 diff --git a/base_search_fuzzy/tests/__init__.py b/base_search_fuzzy/tests/__init__.py index b45665e42..3363cb44c 100644 --- a/base_search_fuzzy/tests/__init__.py +++ b/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 diff --git a/base_search_fuzzy/tests/test_query_generation.py b/base_search_fuzzy/tests/test_query_generation.py index 34c7e30b3..a38534828 100644 --- a/base_search_fuzzy/tests/test_query_generation.py +++ b/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