Skip to content

Commit 18d1adc

Browse files
committed
[ADD] vcp_github
1 parent 4c38c19 commit 18d1adc

22 files changed

Lines changed: 1401 additions & 0 deletions

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# generated from manifests external_dependencies
2+
github3

vcp_github/README.rst

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
==========
2+
Vcp Github
3+
==========
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:086596db3dcb4fa7565fc97cf01ccd22449731243622d4587a1f609eab8bc121
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fversion--control--platform-lightgray.png?logo=github
20+
:target: https://github.com/OCA/version-control-platform/tree/18.0/vcp_github
21+
:alt: OCA/version-control-platform
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/version-control-platform-18-0/version-control-platform-18-0-vcp_github
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/version-control-platform&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
[ This file must be max 2-3 paragraphs, and is required.
32+
33+
The goal of this document is to explain quickly the features of this
34+
module: “what” this module does and “what” it is for. ]
35+
36+
Example:
37+
38+
This module extends the functionality of ... to support ... and to allow
39+
users to ...
40+
41+
**Table of contents**
42+
43+
.. contents::
44+
:local:
45+
46+
Use Cases / Context
47+
===================
48+
49+
[ This file is optional but strongly suggested to allow end-users to
50+
evaluate the module's usefulness in their context. ]
51+
52+
BUSINESS NEED: It should explain the “why” of the module:
53+
54+
- what is the business requirement that generated the need to develop
55+
this module
56+
- in which context or use cases this module can be useful (practical
57+
examples are welcome!).
58+
59+
APPROACH: It could also explain the approach to address the mentioned
60+
need.
61+
62+
USEFUL INFORMATION: It can also inform on related modules:
63+
64+
- modules it depends on and their features
65+
- other modules that can work well together with this one
66+
- suggested setups where the module is useful (eg: multicompany,
67+
multi-website)
68+
69+
Installation
70+
============
71+
72+
[ This file must only be present if there are very specific installation
73+
instructions, such as installing non-python dependencies. The audience
74+
is systems administrators. ]
75+
76+
To install this module, you need to:
77+
78+
1. Do this ...
79+
80+
Configuration
81+
=============
82+
83+
[ This file is not always required; it should explain **how to configure
84+
the module before using it**; it is aimed at users with administration
85+
privileges.
86+
87+
Please be detailed on the path to configuration (eg: do you need to
88+
activate developer mode?), describe step by step configurations and the
89+
use of screenshots is strongly recommended.]
90+
91+
To configure this module, you need to:
92+
93+
- Go to *App* > Menu > Menu item
94+
- Activate boolean… > save
95+
- …
96+
97+
Usage
98+
=====
99+
100+
[ This file is required and contains the instructions on **“how”** to
101+
use the module for end-users.
102+
103+
If the module does not have a visible impact on the user interface, just
104+
add the following sentence:
105+
106+
This module does not impact the user interface.
107+
108+
If that’s not the case, please make sure that every usage step is
109+
covered and remember that images speak more than words!]
110+
111+
To use this module, you need to:
112+
113+
- Go to *App* > Menu > Menu item
114+
115+
*insert screenshot!*
116+
117+
- In “Contact” form, add a value to field *xyz* > save
118+
119+
*insert screenshot!*
120+
121+
- The value of *xyz* is now displayed in the list view.
122+
123+
*insert screenshot!*
124+
125+
Known issues / Roadmap
126+
======================
127+
128+
[ Enumerate known caveats and future potential improvements. It is
129+
mostly intended for end-users, and can also help potential new
130+
contributors discovering new features to implement. ]
131+
132+
- ...
133+
134+
Changelog
135+
=========
136+
137+
[ The change log. The goal of this file is to help readers understand
138+
changes between version. The primary audience is end users and
139+
integrators. Purely technical changes such as code refactoring must not
140+
be mentioned here.
141+
142+
This file may contain ONE level of section titles, underlined with the ~
143+
(tilde) character. Other section markers are forbidden and will likely
144+
break the structure of the README.rst or other documents where this
145+
fragment is included. ]
146+
147+
11.0.x.y.z (YYYY-MM-DD)
148+
-----------------------
149+
150+
- [BREAKING] Breaking changes come first.
151+
(`#70 <https://github.com/OCA/repo/issues/70>`__)
152+
- [ADD] New feature. (`#74 <https://github.com/OCA/repo/issues/74>`__)
153+
- [FIX] Correct this. (`#71 <https://github.com/OCA/repo/issues/71>`__)
154+
155+
11.0.x.y.z (YYYY-MM-DD)
156+
-----------------------
157+
158+
- ...
159+
160+
Bug Tracker
161+
===========
162+
163+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/version-control-platform/issues>`_.
164+
In case of trouble, please check there if your issue has already been reported.
165+
If you spotted it first, help us to smash it by providing a detailed and welcomed
166+
`feedback <https://github.com/OCA/version-control-platform/issues/new?body=module:%20vcp_github%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
167+
168+
Do not contact contributors directly about support or help with technical issues.
169+
170+
Credits
171+
=======
172+
173+
Authors
174+
-------
175+
176+
* Dixmit
177+
178+
Contributors
179+
------------
180+
181+
- Firstname Lastname email.address@example.org (optional company website
182+
url)
183+
- Second Person second.person@example.org (optional company website url)
184+
185+
Other credits
186+
-------------
187+
188+
[ This file is optional and contains additional credits, other than
189+
authors, contributors, and maintainers. ]
190+
191+
The development of this module has been financially supported by:
192+
193+
- Company 1 name
194+
- Company 2 name
195+
196+
Maintainers
197+
-----------
198+
199+
This module is maintained by the OCA.
200+
201+
.. image:: https://odoo-community.org/logo.png
202+
:alt: Odoo Community Association
203+
:target: https://odoo-community.org
204+
205+
OCA, or the Odoo Community Association, is a nonprofit organization whose
206+
mission is to support the collaborative development of Odoo features and
207+
promote its widespread use.
208+
209+
This module is part of the `OCA/version-control-platform <https://github.com/OCA/version-control-platform/tree/18.0/vcp_github>`_ project on GitHub.
210+
211+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

vcp_github/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

vcp_github/__manifest__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2026 Dixmit
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Vcp Github",
6+
"summary": """Integrate Virtual Control Platform with Github""",
7+
"version": "18.0.1.0.0",
8+
"license": "AGPL-3",
9+
"author": "Dixmit,Odoo Community Association (OCA)",
10+
"website": "https://github.com/OCA/version-control-platform",
11+
"depends": [
12+
"vcp",
13+
],
14+
"external_dependencies": {
15+
"python": ["github3"],
16+
},
17+
"data": [],
18+
"demo": [],
19+
}

vcp_github/models/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import vcp_platform
2+
from . import vcp_repository
3+
from . import res_partner

vcp_github/models/res_partner.py

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Copyright 2026 Dixmit
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
import github3
5+
6+
from odoo import fields, models, tools
7+
8+
9+
class ResPartner(models.Model):
10+
_inherit = "res.partner"
11+
12+
github_name = fields.Char(
13+
string="GitHub Username",
14+
help="GitHub username of the contributor or organization",
15+
readonly=True,
16+
)
17+
github_organization = fields.Boolean(
18+
string="Is GitHub Organization",
19+
help="Check if this partner represents a GitHub organization",
20+
readonly=True,
21+
)
22+
github_user = fields.Boolean(
23+
string="Is GitHub User",
24+
help="Check if this partner represents a GitHub user",
25+
readonly=True,
26+
)
27+
28+
_sql_constraints = [
29+
(
30+
"github_name_uniq",
31+
"unique(github_name)",
32+
"The GitHub username must be unique across partners.",
33+
),
34+
]
35+
36+
@tools.ormcache("github_login")
37+
def _get_github_user_id(self, github_login):
38+
partner = self.with_context(active_test=False).search(
39+
[("github_name", "=ilike", github_login)], limit=1
40+
)
41+
if not partner:
42+
return False
43+
if not partner.github_user:
44+
partner.github_user = True
45+
return partner.id
46+
47+
@tools.ormcache("github_login")
48+
def _get_github_organization_id(self, github_login):
49+
partner = self.with_context(active_test=False).search(
50+
[("github_name", "=ilike", github_login)], limit=1
51+
)
52+
if not partner:
53+
return False
54+
if not partner.github_organization:
55+
partner.github_organization = True
56+
return partner.id
57+
58+
def _get_github_user(self, gh, client):
59+
if not gh:
60+
return False
61+
if isinstance(gh, github3.users.User):
62+
github_login = gh.login
63+
else:
64+
github_login = str(gh)
65+
partner = self._get_github_user_id(github_login)
66+
if partner:
67+
return partner
68+
if isinstance(gh, str):
69+
try:
70+
gh = client.user(github_login)
71+
name = gh.name or github_login
72+
except github3.exceptions.NotFoundError:
73+
name = gh
74+
else:
75+
if hasattr(gh, "name"):
76+
name = gh.name or github_login
77+
else:
78+
name = github_login
79+
self.env.registry.clear_cache()
80+
return self.create(
81+
{
82+
"name": name,
83+
"github_name": github_login,
84+
"github_user": True,
85+
}
86+
).id
87+
88+
def _get_github_organization(self, gh, client):
89+
if not gh:
90+
return False
91+
partner = self._get_github_organization_id(str(gh))
92+
if partner:
93+
return partner
94+
self.env.registry.clear_cache()
95+
try:
96+
org = client.organization(str(gh))
97+
98+
return self.create(
99+
{
100+
"name": org.name or str(gh),
101+
"github_name": str(gh),
102+
"github_organization": True,
103+
}
104+
).id
105+
except github3.exceptions.NotFoundError:
106+
user = client.user(str(gh))
107+
name = user.name or str(gh)
108+
except github3.exceptions.ForbiddenError:
109+
name = str(gh)
110+
return self.create(
111+
{
112+
"name": name,
113+
"github_name": str(gh),
114+
"github_user": True,
115+
"github_organization": True,
116+
}
117+
).id
118+
119+
def _get_contributor_url(self):
120+
result = super()._get_contributor_url()
121+
if not result and self.github_name:
122+
return f"https://github.com/{self.github_name}"
123+
return result

0 commit comments

Comments
 (0)