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.

37 lines
1.3KB

  1. # Copyright (C) 2016-Today: Odoo Community Association (OCA)
  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 collections import defaultdict
  5. import requests
  6. from odoo import api, fields, models
  7. class GithubRepository(models.Model):
  8. _inherit = "github.repository"
  9. runbot_id_external = fields.Integer(
  10. string="ID For Runbot",
  11. readonly=True,
  12. store=True,
  13. compute="_compute_runbot_id_external",
  14. )
  15. # Compute Section
  16. @api.depends("organization_id.runbot_parse_url")
  17. def _compute_runbot_id_external(self):
  18. url_done = defaultdict(list)
  19. for repository in self:
  20. url_done[repository.organization_id].append(repository)
  21. for organization_id, repositories in url_done.items():
  22. if organization_id.runbot_parse_url:
  23. req = requests.get(organization_id.runbot_parse_url, timeout=10)
  24. runbot_list = req.content.decode().split("\n")
  25. for item in runbot_list:
  26. for repository in repositories:
  27. if item.endswith(repository.complete_name):
  28. repository.runbot_id_external = item.split("|")[0]
上海开阖软件有限公司 沪ICP备12045867号-1