Skip to content

Commit 8164644

Browse files
committed
[MIG] github_connector/github_connector_odoo: Migration to 19.0
1 parent 36a7cc3 commit 8164644

26 files changed

+360
-257
lines changed

github_connector/README.rst

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
15
================
26
Github Connector
37
================
@@ -13,17 +17,17 @@ Github Connector
1317
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1418
:target: https://odoo-community.org/page/development-status
1519
:alt: Beta
16-
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
1721
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1822
:alt: License: AGPL-3
1923
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Finterface--github-lightgray.png?logo=github
20-
:target: https://github.com/OCA/interface-github/tree/18.0/github_connector
24+
:target: https://github.com/OCA/interface-github/tree/19.0/github_connector
2125
:alt: OCA/interface-github
2226
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/interface-github-18-0/interface-github-18-0-github_connector
27+
:target: https://translation.odoo-community.org/projects/interface-github-19-0/interface-github-19-0-github_connector
2428
:alt: Translate me on Weblate
2529
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/interface-github&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/interface-github&target_branch=19.0
2731
:alt: Try me on Runboat
2832

2933
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -107,7 +111,7 @@ This module provides 4 crons that you can enable:
107111
- Download Source Code for All Github Branches (``cron_download_code``)
108112
- Analyze Source Code for All Github Branches (``cron_analyze_code``)
109113

110-
.. |image| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/github_settings.png
114+
.. |image| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/github_settings.png
111115

112116
Usage
113117
=====
@@ -294,23 +298,23 @@ This module provides several reports
294298

295299
|github_repository_branch_rule_info_report|
296300

297-
.. |sync_organization| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/sync_organization.png
298-
.. |github_organization_kanban| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/github_organization_kanban.png
299-
.. |github_organization_series| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/github_organization_series.png
300-
.. |github_organization_external_services| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/github_organization_external_services.png
301-
.. |github_organization_sync_buttons| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/github_organization_sync_buttons.png
302-
.. |github_team_kanban| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/github_team_kanban.png
303-
.. |github_team_partner_kanban| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/github_team_partner_kanban.png
304-
.. |github_team_repository_kanban| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/github_team_repository_kanban.png
305-
.. |github_repository_kanban| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/github_repository_kanban.png
306-
.. |github_repository_branch_kanban| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/github_repository_branch_kanban.png
307-
.. |wizard_download_analyze| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/wizard_download_analyze.png
308-
.. |github_repository_branch_list| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/github_repository_branch_list.png
309-
.. |wizard_create_team| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/wizard_create_team.png
310-
.. |wizard_create_repository| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/wizard_create_repository.png
311-
.. |reporting_branches_by_serie| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/reporting_branches_by_serie.png
312-
.. |reporting_sizes_by_serie| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/reporting_sizes_by_serie.png
313-
.. |github_repository_branch_rule_info_report| image:: https://raw.githubusercontent.com/OCA/interface-github/18.0/github_connector/static/description/github_repository_branch_rule_info_report.png
301+
.. |sync_organization| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/sync_organization.png
302+
.. |github_organization_kanban| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/github_organization_kanban.png
303+
.. |github_organization_series| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/github_organization_series.png
304+
.. |github_organization_external_services| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/github_organization_external_services.png
305+
.. |github_organization_sync_buttons| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/github_organization_sync_buttons.png
306+
.. |github_team_kanban| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/github_team_kanban.png
307+
.. |github_team_partner_kanban| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/github_team_partner_kanban.png
308+
.. |github_team_repository_kanban| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/github_team_repository_kanban.png
309+
.. |github_repository_kanban| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/github_repository_kanban.png
310+
.. |github_repository_branch_kanban| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/github_repository_branch_kanban.png
311+
.. |wizard_download_analyze| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/wizard_download_analyze.png
312+
.. |github_repository_branch_list| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/github_repository_branch_list.png
313+
.. |wizard_create_team| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/wizard_create_team.png
314+
.. |wizard_create_repository| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/wizard_create_repository.png
315+
.. |reporting_branches_by_serie| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/reporting_branches_by_serie.png
316+
.. |reporting_sizes_by_serie| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/reporting_sizes_by_serie.png
317+
.. |github_repository_branch_rule_info_report| image:: https://raw.githubusercontent.com/OCA/interface-github/19.0/github_connector/static/description/github_repository_branch_rule_info_report.png
314318

315319
Known issues / Roadmap
316320
======================
@@ -345,7 +349,7 @@ Bug Tracker
345349
Bugs are tracked on `GitHub Issues <https://github.com/OCA/interface-github/issues>`_.
346350
In case of trouble, please check there if your issue has already been reported.
347351
If you spotted it first, help us to smash it by providing a detailed and welcomed
348-
`feedback <https://github.com/OCA/interface-github/issues/new?body=module:%20github_connector%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
352+
`feedback <https://github.com/OCA/interface-github/issues/new?body=module:%20github_connector%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
349353

350354
Do not contact contributors directly about support or help with technical issues.
351355

@@ -390,6 +394,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
390394
mission is to support the collaborative development of Odoo features and
391395
promote its widespread use.
392396

393-
This module is part of the `OCA/interface-github <https://github.com/OCA/interface-github/tree/18.0/github_connector>`_ project on GitHub.
397+
This module is part of the `OCA/interface-github <https://github.com/OCA/interface-github/tree/19.0/github_connector>`_ project on GitHub.
394398

395399
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

github_connector/__manifest__.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
{
88
"name": "Github Connector",
99
"summary": "Synchronize information from Github repositories",
10-
"version": "18.0.1.0.0",
10+
"version": "19.0.1.0.0",
1111
"category": "Connector",
1212
"license": "AGPL-3",
1313
"author": "Odoo Community Association (OCA), GRAP, Akretion, Tecnativa",
1414
"website": "https://github.com/OCA/interface-github",
15-
"depends": ["base", "web"],
15+
"depends": [
16+
"base",
17+
"web",
18+
],
1619
"data": [
1720
"security/ir_model_category.xml",
1821
"security/res_groups.xml",
@@ -44,9 +47,18 @@
4447
],
4548
"installable": True,
4649
"external_dependencies": {
47-
"python": ["GitPython", "pathspec", "PyGithub"],
48-
"bin": ["cloc"],
50+
"python": [
51+
"GitPython",
52+
"pathspec",
53+
"PyGithub",
54+
"responses",
55+
],
56+
"bin": [
57+
"cloc",
58+
],
4959
# special definition used by OCA to install packages
50-
"deb": ["cloc"],
60+
"deb": [
61+
"cloc",
62+
],
5163
},
5264
}

github_connector/models/abstract_github_model.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from urllib.request import urlopen
1010

1111
import pytz
12-
from github import Auth, Github # pylint: disable=missing-manifest-dependency
13-
from github.GithubException import ( # pylint: disable=missing-manifest-dependency
12+
from github import Auth, Github
13+
from github.GithubException import (
1414
UnknownObjectException,
1515
)
1616

@@ -284,10 +284,9 @@ def _update_from_github_data(self, data):
284284
item.write(to_write)
285285

286286
def get_github_connector(self):
287-
ICP = self.env["ir.config_parameter"]
288-
token = tools.config.get("github_token") or ICP.get_param(
289-
"github.access_token", default=""
290-
)
287+
token = tools.config.get("github_token") or self.env[
288+
"ir.config_parameter"
289+
].sudo().get_param("github.access_token", default="")
291290
if not token:
292291
raise UserError(
293292
self.env._(

github_connector/models/github_organization.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
55
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
66

7-
# pylint: disable=missing-manifest-dependency
87
from github.GithubException import GithubException
98

109
from odoo import api, exceptions, fields, models
@@ -106,6 +105,7 @@ def full_update(self):
106105

107106
@api.model
108107
def cron_update_organization_team(self):
108+
# pylint: disable=no-search-all
109109
organizations = self.search([])
110110
organizations.full_update()
111111
organizations.mapped("team_ids").full_update()
@@ -119,40 +119,34 @@ def _compute_member_qty(self):
119119

120120
@api.depends("repository_ids.organization_id")
121121
def _compute_repository_qty(self):
122-
data = self.env["github.repository"].read_group(
122+
data = self.env["github.repository"]._read_group(
123123
[("organization_id", "in", self.ids)],
124-
["organization_id"],
125-
["organization_id"],
124+
groupby=["organization_id"],
125+
aggregates=["__count"],
126126
)
127-
mapping = {
128-
data["organization_id"][0]: data["organization_id_count"] for data in data
129-
}
127+
mapping = {org.id: count for org, count in data}
130128
for item in self:
131129
item.repository_qty = mapping.get(item.id, 0)
132130

133131
@api.depends("team_ids.organization_id")
134132
def _compute_team_qty(self):
135-
data = self.env["github.team"].read_group(
133+
data = self.env["github.team"]._read_group(
136134
[("organization_id", "in", self.ids)],
137-
["organization_id"],
138-
["organization_id"],
135+
groupby=["organization_id"],
136+
aggregates=["__count"],
139137
)
140-
mapping = {
141-
data["organization_id"][0]: data["organization_id_count"] for data in data
142-
}
138+
mapping = {org.id: count for org, count in data}
143139
for item in self:
144140
item.team_qty = mapping.get(item.id, 0)
145141

146142
@api.depends("organization_serie_ids.organization_id")
147143
def _compute_organization_serie_qty(self):
148-
data = self.env["github.organization.serie"].read_group(
144+
data = self.env["github.organization.serie"]._read_group(
149145
[("organization_id", "in", self.ids)],
150-
["organization_id"],
151-
["organization_id"],
146+
groupby=["organization_id"],
147+
aggregates=["__count"],
152148
)
153-
mapping = {
154-
data["organization_id"][0]: data["organization_id_count"] for data in data
155-
}
149+
mapping = {org.id: count for org, count in data}
156150
for item in self:
157151
item.organization_serie_qty = mapping.get(item.id, 0)
158152

github_connector/models/github_organization_serie.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ class GithubOrganizationSerie(models.Model):
2020
required=True,
2121
)
2222

23-
_sql_constraints = [
24-
(
25-
"sequence_organization_uniq",
26-
"unique(organization_id, sequence)",
27-
"Sequence serie must be unique by organization.",
28-
)
29-
]
23+
_sequence_organization_uniq = models.Constraint(
24+
"unique(organization_id, sequence)",
25+
"Sequence serie must be unique by organization.",
26+
)

github_connector/models/github_repository.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ def _compute_ignore(self):
8686

8787
@api.depends("team_ids")
8888
def _compute_team_qty(self):
89-
data = self.env["github.team.repository"].read_group(
90-
[("repository_id", "in", self.ids)], ["repository_id"], ["repository_id"]
89+
data = self.env["github.team.repository"]._read_group(
90+
[("repository_id", "in", self.ids)],
91+
groupby=["repository_id"],
92+
aggregates=["__count"],
9193
)
92-
mapping = {
93-
data["repository_id"][0]: data["repository_id_count"] for data in data
94-
}
94+
mapping = {repo.id: count for repo, count in data}
9595
for item in self:
9696
item.team_qty = mapping.get(item.id, 0)
9797

@@ -104,12 +104,12 @@ def _compute_complete_name(self):
104104

105105
@api.depends("repository_branch_ids.repository_id")
106106
def _compute_repository_branch_qty(self):
107-
data = self.env["github.repository.branch"].read_group(
108-
[("repository_id", "in", self.ids)], ["repository_id"], ["repository_id"]
107+
data = self.env["github.repository.branch"]._read_group(
108+
[("repository_id", "in", self.ids)],
109+
groupby=["repository_id"],
110+
aggregates=["__count"],
109111
)
110-
mapping = {
111-
data["repository_id"][0]: data["repository_id_count"] for data in data
112-
}
112+
mapping = {repo.id: count for repo, count in data}
113113
for item in self:
114114
item.repository_branch_qty = mapping.get(item.id, 0)
115115

@@ -173,6 +173,7 @@ def full_update(self):
173173

174174
@api.model
175175
def cron_update_branch_list(self):
176+
# pylint: disable=no-search-all
176177
branches = self.search([])
177178
branches.button_sync_branch()
178179
return True
@@ -196,9 +197,13 @@ def button_sync_branch(self):
196197
branch_ids.append(branch.id)
197198
else:
198199
_logger.warning(
199-
"the branch '%s'/'%s' has been ignored.",
200+
"The branch '%s'/'%s' has been ignored because '%s' is not "
201+
"configured as a series for organization '%s'. "
202+
"Please add this series in the organization configuration.",
200203
repository.name,
201204
gh_branch.name,
205+
gh_branch.name,
206+
repository.organization_id.name,
202207
)
203208
repository.repository_branch_ids = [(6, 0, branch_ids)]
204209

0 commit comments

Comments
 (0)