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.

35 lines
1.2KB

  1. # Copyright 2020 Tecnativa - Víctor Martínez
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import api, fields, models
  4. class GithubAnalysisRuleInfoMixin(models.AbstractModel):
  5. _name = "github.analysis.rule.info.mixin"
  6. _description = "Github Analysis Rule Mixin"
  7. analysis_rule_id = fields.Many2one(
  8. string="Analysis Rule", comodel_name="github.analysis.rule",
  9. )
  10. group_id = fields.Many2one(
  11. string="Group", related="analysis_rule_id.group_id", readonly=True
  12. )
  13. code_count = fields.Integer(string="# Code")
  14. documentation_count = fields.Integer(string="# Doc.")
  15. empty_count = fields.Integer(string="# Empty")
  16. string_count = fields.Integer(string="# String")
  17. total_count = fields.Integer(
  18. string="# Total", store=True, compute="_compute_total_count"
  19. )
  20. scanned_files = fields.Integer(string="Scanned files")
  21. @api.depends("code_count", "documentation_count", "empty_count", "string_count")
  22. def _compute_total_count(self):
  23. for item in self:
  24. item.total_count = (
  25. item.code_count
  26. + item.documentation_count
  27. + item.empty_count
  28. + item.string_count
  29. )
上海开阖软件有限公司 沪ICP备12045867号-1