Advertisement
Guest User

Untitled

a guest
Nov 10th, 2011
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. working:
  2.  
  3. categories_string = fields.Function(fields.Char('Categories'), '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. development (and not working):
  14.  
  15. def search_categories_string(self, name, clause):
  16. res = []
  17. value = clause[3]
  18. for cat, _ in self.categories:
  19. if isinstance(value, basestring) \
  20. and cat.rec_name \
  21. and value.upper() in cat.rec_name.upper():
  22. res.append(('categories', '=', cat.rec_name))
  23. value = value[len(cat.rec_name):]
  24. break
  25. res.append(('categories', clause[1], value))
  26. return res
  27.  
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement