Skip to content

Commit

Permalink
Improve custom tags computation
Browse files Browse the repository at this point in the history
The field `tag_ids` is resource-consuming in comparison to the other
fields, making the display of the suggestions significantly slower.

In case no custom tags are used, we simplify the assignation of the
value.
  • Loading branch information
DocMarty84 committed Nov 24, 2019
1 parent 43d404d commit f541d85
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion models/oomusic_preference.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ def _search_bit_follow(self, operator, value):

@api.depends("pref_ids")
def _compute_tag_ids(self):
self.env.cr.execute("SELECT true FROM oomusic_preference_oomusic_tag_rel LIMIT 1")
row = self.env.cr.fetchone()
for obj in self:
obj.tag_ids = obj._get_pref("tag_ids")
obj.tag_ids = obj._get_pref("tag_ids") if row else False

def _inverse_tag_ids(self):
for obj in self:
Expand Down

0 comments on commit f541d85

Please sign in to comment.