Created
April 11, 2016 15:43
-
-
Save gurneyalex/b571449b4e698b3635d13aba674ca392 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A(Model): | |
def _compute_B_count(self): | |
query = 'select a.id, count(b.id) from a right outer join b on (a.id=b.a_id) where a.id = ANY(%s)' | |
self.env.cr.execute(query, self.ids) | |
counts = dict(self.env.cr.fetchall()) | |
for rec in self: | |
rec.count = counts[rec.id] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment