Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- categories_string = fields.Function(fields.Char('Categories'
- #, order_field='aikidokas.get_categories_string %(order)s, aikidokas.name %(order)s'
- ), '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))
- if 'Fukushidoin, ' in res[party.id]:
- res[party.id] = res[party.id].replace('Fukushidoin, ', '') + ', Fukushidoin'
- if 'Shidoin, ' in res[party.id]:
- res[party.id] = res[party.id].replace('Shidoin, ', '') + ', Shidoin'
- if 'Dojocho, ' in res[party.id]:
- res[party.id] = res[party.id].replace('Dojocho, ', '') + ', Dojocho'
- if ', Dojo' == res[party.id][-6:]:
- res[party.id] = 'Dojo, ' + res[party.id][:len(res[party.id])-6]
- return res
- def search_categories_string(self, name, clause):
- ids = self.search([('name', '!=', '')], order=[])
- 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