Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- categories_string = fields.Function(fields.Char('Categories'
- #, order_field='partys.get_categories_string %(order)s, partys.name %(order)s'#FIXME enable ordering in tree
- ), 'get_categories_string', searcher='search_categories_string')
- def get_categories_string(self, ids, name):
- if not ids:
- return []
- res = {}
- for party in self.browse(ids):
- res[party.id] = ', '.join(sorted(cat.rec_name for cat in party.categories))
- return res
- def search_categories_string(self, name, clause):
- ids = self.search([('name', '!=', '')], order=[])#FIXME optimise this
- res = []
- value = clause[2]
- cats = self.get_categories_string(ids, name)
- for cat in cats.keys():
- if value.lower() in cats[cat].lower():
- res.append('categories', '=', cats[cat])
- res.append(('categories', clause[1], value))
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement