You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.1 KiB

  1. # Copyright (C) 2018 - TODAY, Open Source Integrators
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import api, fields, models
  4. class Agreement(models.Model):
  5. _inherit = "agreement"
  6. picking_count = fields.Integer('# Pickings',
  7. compute='_compute_picking_count')
  8. move_count = fields.Integer('# Moves', compute='_compute_move_count')
  9. lot_count = fields.Integer('# Lots/Serials', compute='_compute_lot_count')
  10. @api.multi
  11. def _compute_picking_count(self):
  12. for ag_rec in self:
  13. ag_rec.picking_count = self.env['stock.picking'].search_count(
  14. [('agreement_id', 'in', ag_rec.ids)])
  15. @api.multi
  16. def _compute_move_count(self):
  17. for ag_rec in self:
  18. ag_rec.move_count = self.env['stock.move'].search_count(
  19. [('agreement_id', 'in', ag_rec.ids)])
  20. @api.multi
  21. def _compute_lot_count(self):
  22. for ag_rec in self:
  23. ag_rec.lot_count = self.env['stock.production.lot'].search_count(
  24. [('agreement_id', 'in', ag_rec.ids)])