mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[ADD] agreement_mrp
This commit is contained in:
committed by
Murtaza Mithaiwala
parent
929495172c
commit
f67a9d4bd8
20
agreement_mrp/models/agreement.py
Normal file
20
agreement_mrp/models/agreement.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# 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"
|
||||
|
||||
mo_count = fields.Integer('# MOs', compute='_compute_mo_count')
|
||||
|
||||
@api.multi
|
||||
def _compute_mo_count(self):
|
||||
data = self.env['mrp.production'].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.mo_count = count_data.get(agreement.id, 0)
|
||||
Reference in New Issue
Block a user