From 0e9095bef888c3cebea8ca16b8ed0dc0656187d2 Mon Sep 17 00:00:00 2001 From: Yves Goldberg Date: Thu, 4 Apr 2019 14:28:38 +0200 Subject: [PATCH] [UPD][IMP] @murtuzasaleh remarks + search_count [UPD] @murtuzasaleh remarks for readme.rst [IMP] use search_count --- agreement_project/README.rst | 8 ++++---- agreement_project/models/agreement.py | 11 ++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/agreement_project/README.rst b/agreement_project/README.rst index bdee9ca6..9320be6e 100644 --- a/agreement_project/README.rst +++ b/agreement_project/README.rst @@ -14,13 +14,13 @@ Agreement - Project :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github - :target: https://github.com/OCA/contract/tree/11.0/agreement_project + :target: https://github.com/OCA/contract/tree/12.0/agreement_project :alt: OCA/contract .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/contract-11-0/contract-11-0-agreement_project + :target: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-agreement_project :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/110/11.0 + :target: https://runbot.odoo-community.org/runbot/110/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -107,6 +107,6 @@ Current `maintainers `__: |maintainer-smangukiya| |maintainer-max3903| -This module is part of the `OCA/contract `_ project on GitHub. +This module is part of the `OCA/contract `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/agreement_project/models/agreement.py b/agreement_project/models/agreement.py index d88991fe..9c6311b3 100644 --- a/agreement_project/models/agreement.py +++ b/agreement_project/models/agreement.py @@ -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