[UPD][IMP] @murtuzasaleh remarks + search_count

[UPD] @murtuzasaleh remarks for readme.rst

[IMP] use search_count
This commit is contained in:
Yves Goldberg
2019-04-04 14:28:38 +02:00
parent 6aee2bc19f
commit 0e9095bef8
2 changed files with 8 additions and 11 deletions

View File

@@ -12,10 +12,7 @@ class Agreement(models.Model):
@api.multi
def _compute_task_count(self):
data = self.env['project.task'].read_group(
[('agreement_id', 'in', self.ids)],
['agreement_id'], ['agreement_id'])
count_data = dict((item['agreement_id'][0],
item['agreement_id_count']) for item in data)
for agreement in self:
agreement.task_count = count_data.get(agreement.id, 0)
for ag in self:
count = self.env['project.task'].search_count(
[('agreement_id', 'in', self.ids)])
ag.task_count = count