Advertisement
Guest User

Untitled

a guest
Nov 14th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. categories_string = fields.Function(fields.Char('Categories'
  2. #, order_field='partys.get_categories_string %(order)s, partys.name %(order)s'#FIXME enable ordering in tree
  3. ), 'get_categories_string', searcher='search_categories_string')
  4.  
  5. def get_categories_string(self, ids, name):
  6. if not ids:
  7. return []
  8. res = {}
  9. for party in self.browse(ids):
  10. res[party.id] = ', '.join(sorted(cat.rec_name for cat in party.categories))
  11. return res
  12.  
  13. def search_categories_string(self, name, clause):
  14. ids = self.search([('name', '!=', '')], order=[])#FIXME optimise this
  15. res = []
  16. value = clause[2]
  17. cats = self.get_categories_string(ids, name)
  18. for cat in cats.keys():
  19. if value.lower() in cats[cat].lower():
  20. res.append('categories', '=', cats[cat])
  21. res.append(('categories', clause[1], value))
  22. return res
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement