| 1 |
|
| 2 |
|
| 3 |
from odoo import models |
| 4 |
from odoo.tools import SQL |
| 5 |
|
| 6 |
|
| 7 |
class IrAttachment(models.Model): |
| 8 |
_inherit = 'ir.attachment' |
| 9 |
|
| 10 |
def init(self): |
| 11 |
if self.env.registry.has_trigram: |
| 12 |
indexed_field = SQL('UNACCENT(index_content)') if self.env.registry.has_unaccent else SQL('index_content') |
| 13 |
|
| 14 |
self.env.cr.execute(SQL(''' |
| 15 |
CREATE INDEX IF NOT EXISTS ir_attachment_index_content_applicant_trgm_idx |
| 16 |
ON ir_attachment USING gin (%(indexed_field)s gin_trgm_ops) |
| 17 |
WHERE res_model = 'hr.applicant' |
| 18 |
''', indexed_field=indexed_field)) |