Files
contract/agreement_project/models/agreement.py
Yves Goldberg 7718193678 [UPD][IMP] @murtuzasaleh remarks + search_count
[UPD] @murtuzasaleh remarks for readme.rst

[IMP] use search_count
2021-07-01 17:14:34 +05:30

19 lines
543 B
Python

# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class Agreement(models.Model):
_inherit = "agreement"
task_count = fields.Integer('# Tasks',
compute='_compute_task_count')
@api.multi
def _compute_task_count(self):
for ag in self:
count = self.env['project.task'].search_count(
[('agreement_id', 'in', self.ids)])
ag.task_count = count