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.

30 lines
1000 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. installed_module_ids = fields.One2many(
  12. string='Installed Modules', comodel_name='ir.module.module',
  13. inverse_name='module_type_id')
  14. installed_module_qty = fields.Integer(
  15. string='Modules Quantity', compute='_compute_installed_module_qty',
  16. store=True)
  17. @api.multi
  18. @api.depends('installed_module_ids.module_type_id')
  19. def _compute_installed_module_qty(self):
  20. for module_type in self:
  21. module_type.installed_module_qty = len(
  22. module_type.installed_module_ids)