Skip to content

Commit

Permalink
Merge b3ce1f5 into 081e04e
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim committed Dec 16, 2019
2 parents 081e04e + b3ce1f5 commit 239fa9f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions project_task_code/models/project_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models, _
from odoo.osv import expression


class ProjectTask(models.Model):
Expand Down Expand Up @@ -48,3 +49,18 @@ def name_get(self):
name = '[%s] %s' % (rec.code, task[1])
new_result.append((rec.id, name))
return new_result

@api.model
def name_search(self, name, args=None, operator='ilike', limit=100):
args = args or []
domain = []
if name:
domain = [
'|',
('code', '=ilike', '%' + name + '%'),
('name', operator, name)
]
if operator in expression.NEGATIVE_TERM_OPERATORS:
domain = ['&', '!'] + domain[1:]
tasks = self.search(domain + args, limit=limit)
return tasks.name_get()

0 comments on commit 239fa9f

Please sign in to comment.