Browse Source

[UPD][IMP] @murtuzasaleh remarks + search_count

[UPD] @murtuzasaleh remarks for readme.rst

[IMP] use search_count
pull/305/head
Yves Goldberg 5 years ago
parent
commit
0e9095bef8
  1. 8
      agreement_project/README.rst
  2. 11
      agreement_project/models/agreement.py

8
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 <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-smangukiya| |maintainer-max3903|
This module is part of the `OCA/contract <https://github.com/OCA/contract/tree/11.0/agreement_project>`_ project on GitHub.
This module is part of the `OCA/contract <https://github.com/OCA/contract/tree/12.0/agreement_project>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

11
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
Loading…
Cancel
Save