mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
# Copyright (C) 2021 - TODAY, Open Source Integrators
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
|
|
from odoo import fields, models
|
|
|
|
|
|
class Agreement(models.Model):
|
|
_inherit = "agreement"
|
|
|
|
picking_count = fields.Integer("# Pickings", compute="_compute_picking_count")
|
|
move_count = fields.Integer("# Moves", compute="_compute_move_count")
|
|
lot_count = fields.Integer("# Lots/Serials", compute="_compute_lot_count")
|
|
|
|
def _compute_picking_count(self):
|
|
for ag_rec in self:
|
|
ag_rec.picking_count = self.env["stock.picking"].search_count(
|
|
[("agreement_id", "in", ag_rec.ids)]
|
|
)
|
|
|
|
def _compute_move_count(self):
|
|
for ag_rec in self:
|
|
ag_rec.move_count = self.env["stock.move"].search_count(
|
|
[("agreement_id", "in", ag_rec.ids)]
|
|
)
|
|
|
|
def _compute_lot_count(self):
|
|
for ag_rec in self:
|
|
ag_rec.lot_count = self.env["stock.production.lot"].search_count(
|
|
[("agreement_id", "in", ag_rec.ids)]
|
|
)
|