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.

28 lines
895 B

  1. # Copyright (C) 2019-Today: GRAP (<http://www.grap.coop/>)
  2. # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo import api, fields, models
  5. class IrModuleType(models.Model):
  6. _name = 'ir.module.type'
  7. _description = 'Modules Types'
  8. _order = 'sequence'
  9. name = fields.Char(string='Name', required=True)
  10. sequence = fields.Integer(string='Sequence')
  11. module_ids = fields.One2many(
  12. string='Modules', comodel_name='ir.module.module',
  13. inverse_name='module_type_id')
  14. module_qty = fields.Integer(
  15. string='Modules Quantity', compute='_compute_module_qty', store=True)
  16. @api.multi
  17. @api.depends('module_ids.module_type_id')
  18. def _compute_module_qty(self):
  19. for module_type in self:
  20. module_type.module_qty = len(module_type.module_ids)