From 4c38c19eb88cddf25855419a0e88d8a863d9d01b Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Sat, 24 Jan 2026 10:41:21 +0100 Subject: [PATCH 01/11] [ADD] vcp --- vcp/README.rst | 91 ++++ vcp/__init__.py | 2 + vcp/__manifest__.py | 35 ++ vcp/controllers/__init__.py | 1 + vcp/controllers/main.py | 185 ++++++++ vcp/data/ir_cron.xml | 23 + vcp/models/__init__.py | 7 + vcp/models/res_partner.py | 68 +++ vcp/models/vcp_branch.py | 19 + vcp/models/vcp_comment.py | 36 ++ vcp/models/vcp_platform.py | 219 +++++++++ vcp/models/vcp_repository.py | 47 ++ vcp/models/vcp_request.py | 68 +++ vcp/models/vcp_review.py | 38 ++ vcp/pyproject.toml | 3 + vcp/readme/CONTEXT.md | 3 + vcp/readme/CONTRIBUTORS.md | 5 + vcp/readme/DESCRIPTION.md | 1 + vcp/security/ir.model.access.csv | 11 + vcp/static/description/icon.png | Bin 0 -> 2789 bytes vcp/static/description/icon.svg | 75 +++ vcp/static/description/index.html | 438 ++++++++++++++++++ .../popover_tooltip/popover_tooltip.esm.js | 8 + .../popover_tooltip/popover_tooltip.xml | 7 + .../components/vcp_render/vcp_render.esm.js | 122 +++++ .../src/components/vcp_render/vcp_render.scss | 31 ++ .../src/components/vcp_render/vcp_render.xml | 148 ++++++ vcp/static/tests/tours/portal.esm.js | 111 +++++ vcp/templates/templates.xml | 100 ++++ vcp/tests/__init__.py | 1 + vcp/tests/test_portal.py | 125 +++++ vcp/views/menu.xml | 11 + vcp/views/vcp_branch.xml | 27 ++ vcp/views/vcp_comment.xml | 26 ++ vcp/views/vcp_platform.xml | 83 ++++ vcp/views/vcp_repository.xml | 102 ++++ vcp/views/vcp_request.xml | 92 ++++ vcp/views/vcp_review.xml | 27 ++ 38 files changed, 2396 insertions(+) create mode 100644 vcp/README.rst create mode 100644 vcp/__init__.py create mode 100644 vcp/__manifest__.py create mode 100644 vcp/controllers/__init__.py create mode 100644 vcp/controllers/main.py create mode 100644 vcp/data/ir_cron.xml create mode 100644 vcp/models/__init__.py create mode 100644 vcp/models/res_partner.py create mode 100644 vcp/models/vcp_branch.py create mode 100644 vcp/models/vcp_comment.py create mode 100644 vcp/models/vcp_platform.py create mode 100644 vcp/models/vcp_repository.py create mode 100644 vcp/models/vcp_request.py create mode 100644 vcp/models/vcp_review.py create mode 100644 vcp/pyproject.toml create mode 100644 vcp/readme/CONTEXT.md create mode 100644 vcp/readme/CONTRIBUTORS.md create mode 100644 vcp/readme/DESCRIPTION.md create mode 100644 vcp/security/ir.model.access.csv create mode 100644 vcp/static/description/icon.png create mode 100644 vcp/static/description/icon.svg create mode 100644 vcp/static/description/index.html create mode 100644 vcp/static/src/components/popover_tooltip/popover_tooltip.esm.js create mode 100644 vcp/static/src/components/popover_tooltip/popover_tooltip.xml create mode 100644 vcp/static/src/components/vcp_render/vcp_render.esm.js create mode 100644 vcp/static/src/components/vcp_render/vcp_render.scss create mode 100644 vcp/static/src/components/vcp_render/vcp_render.xml create mode 100644 vcp/static/tests/tours/portal.esm.js create mode 100644 vcp/templates/templates.xml create mode 100644 vcp/tests/__init__.py create mode 100644 vcp/tests/test_portal.py create mode 100644 vcp/views/menu.xml create mode 100644 vcp/views/vcp_branch.xml create mode 100644 vcp/views/vcp_comment.xml create mode 100644 vcp/views/vcp_platform.xml create mode 100644 vcp/views/vcp_repository.xml create mode 100644 vcp/views/vcp_request.xml create mode 100644 vcp/views/vcp_review.xml diff --git a/vcp/README.rst b/vcp/README.rst new file mode 100644 index 0000000..8ebbbed --- /dev/null +++ b/vcp/README.rst @@ -0,0 +1,91 @@ +=== +Vcp +=== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e5814614bba4bc7f628d116d3529a253bb2ae9bff8e8a16c3cfc7eefa5def3cf + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fversion--control--platform-lightgray.png?logo=github + :target: https://github.com/OCA/version-control-platform/tree/18.0/vcp + :alt: OCA/version-control-platform +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/version-control-platform-18-0/version-control-platform-18-0-vcp + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/version-control-platform&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Creates a set of modules used for handling a version control patform. + +**Table of contents** + +.. contents:: + :local: + +Use Cases / Context +=================== + +The aim of this module is to allow any community to import data from a +version control system. + +The system should be done in a way that is agnostic to the system and +the connections are handled directly by specific modules. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Dixmit + +Contributors +------------ + +- `Dixmit `__ + + - Enric Tobella + +- `Akretion `__ + + - Sebastien Beau + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/version-control-platform `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/vcp/__init__.py b/vcp/__init__.py new file mode 100644 index 0000000..91c5580 --- /dev/null +++ b/vcp/__init__.py @@ -0,0 +1,2 @@ +from . import controllers +from . import models diff --git a/vcp/__manifest__.py b/vcp/__manifest__.py new file mode 100644 index 0000000..2f85b83 --- /dev/null +++ b/vcp/__manifest__.py @@ -0,0 +1,35 @@ +# Copyright 2025 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Vcp", + "summary": """Virtual Control Platform core module""", + "version": "18.0.1.0.0", + "license": "AGPL-3", + "author": "Dixmit,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/version-control-platform", + "depends": ["website_partner"], + "data": [ + "security/ir.model.access.csv", + "data/ir_cron.xml", + "templates/templates.xml", + "views/menu.xml", + "views/vcp_comment.xml", + "views/vcp_review.xml", + "views/vcp_request.xml", + "views/vcp_repository.xml", + "views/vcp_branch.xml", + "views/vcp_platform.xml", + ], + "demo": [], + "assets": { + "web.assets_frontend": [ + "vcp/static/src/components/**/*.esm.js", + "vcp/static/src/components/**/*.xml", + "vcp/static/src/components/**/*.scss", + ], + "web.assets_tests": [ + "vcp/static/tests/**/*", + ], + }, +} diff --git a/vcp/controllers/__init__.py b/vcp/controllers/__init__.py new file mode 100644 index 0000000..12a7e52 --- /dev/null +++ b/vcp/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/vcp/controllers/main.py b/vcp/controllers/main.py new file mode 100644 index 0000000..f9b2080 --- /dev/null +++ b/vcp/controllers/main.py @@ -0,0 +1,185 @@ +# Copyright 2026 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from math import sqrt + +from odoo import _, http +from odoo.http import request + +from odoo.addons.portal.controllers.portal import CustomerPortal + + +class ContributorsController(CustomerPortal): + @http.route( + [ + "/vcp", + "/vcp/", + ], + type="http", + auth="user", + website=True, + ) + def contributors_vcp(self, vcp=None): + values = self._prepare_portal_layout_values() + values.update(self._prepare_home_portal_values([])) + if vcp is None: + vcps = request.env["vcp.platform"].search([]) + return request.render( + "vcp.vcp_platforms_template", + {"vcps": vcps, **values}, + ) + vcp_id = ( + request.env["vcp.platform"] + .sudo() + .search([("name", "=ilike", vcp)], limit=1) + .id + ) + return request.render( + "vcp.vcp_platform_template", + {"vcp": vcp_id, **values}, + ) + + def _get_index(self, data): + return round( + sqrt(data["created_requests"]) + + data["merged_requests"] + + sqrt(data["comments"]) + + data["reviews"], + 2, + ) + + def _get_field(self, kind): + if kind == "contributors": + return "partner_id" + elif kind == "organizations": + return "organization_id" + elif kind == "repositories": + return "repository_id" + return False + + @http.route(["/vcp-fetch"], type="json", auth="user", readonly=True) + def fetch_vcp_data(self, vcp_id, year, month, kind, period, **values): + vcp = request.env["vcp.platform"].browse(vcp_id).exists() + if not vcp: + return [] + start, end = vcp._get_dates(year, month, period, **values) + data = vcp._generate_data(start, end, self._get_field(kind), kind, **values) + return { + "columns": self._get_vcp_columns(kind), + "data": self._improve_vcp_data(data, kind, **values), + } + + def _get_vcp_columns(self, kind): + if kind == "contributors": + return [ + {"field": "name", "title": _("Name"), "kind": "name"}, + { + "field": "created_requests", + "title": _("Created Requests"), + "kind": "float", + "decimals": 0, + }, + { + "field": "merged_requests", + "title": _("Merged Requests"), + "kind": "float", + "decimals": 0, + }, + { + "field": "comments", + "title": _("Comments"), + "kind": "float", + "decimals": 0, + }, + { + "field": "reviews", + "title": _("Reviews"), + "kind": "float", + "decimals": 0, + }, + ] + elif kind == "organizations": + return [ + {"field": "name", "title": _("Organization Name"), "kind": "name"}, + { + "field": "created_requests", + "title": _("Created Requests"), + "kind": "float", + "decimals": 0, + }, + { + "field": "merged_requests", + "title": _("Merged Requests"), + "kind": "float", + "decimals": 0, + }, + { + "field": "comments", + "title": _("Comments"), + "kind": "float", + "decimals": 0, + }, + { + "field": "reviews", + "title": _("Reviews"), + "kind": "float", + "decimals": 0, + }, + { + "field": "developers", + "title": _("Developers"), + "kind": "float", + "decimals": 0, + }, + ] + elif kind == "repositories": + return [ + {"field": "name", "title": _("Repository Name"), "kind": "name"}, + { + "field": "created_requests", + "title": _("Created Requests"), + "kind": "float", + "decimals": 0, + }, + { + "field": "merged_requests", + "title": _("Merged Requests"), + "kind": "float", + "decimals": 0, + }, + { + "field": "comments", + "title": _("Comments"), + "kind": "float", + "decimals": 0, + }, + { + "field": "reviews", + "title": _("Reviews"), + "kind": "float", + "decimals": 0, + }, + { + "field": "developers", + "title": _("Developers"), + "kind": "float", + "decimals": 0, + }, + ] + return [] + + def _improve_vcp_data(self, data, kind, **kwargs): + for key, values in data.items(): + if kind == "contributors": + partner = request.env["res.partner"].browse(key) + values["name"] = partner._get_contributors_name(kind, **kwargs) + values["url"] = partner._get_contributor_url() + elif kind == "organizations": + organization = request.env["res.partner"].browse(key) + values["name"] = organization._get_contributors_name(kind, **kwargs) + values["url"] = organization._get_contributor_url() + elif kind == "repositories": + repository = request.env["vcp.repository"].browse(key) + values["name"] = repository.name + values["url"] = repository._get_repository_url() + return data diff --git a/vcp/data/ir_cron.xml b/vcp/data/ir_cron.xml new file mode 100644 index 0000000..08a50e6 --- /dev/null +++ b/vcp/data/ir_cron.xml @@ -0,0 +1,23 @@ + + + + + VCP: Repository Update + + code + model._cron_update_repositories() + 1 + minutes + False + + + VCP: Platform Update + + code + model._cron_update_platforms() + 1 + days + False + + diff --git a/vcp/models/__init__.py b/vcp/models/__init__.py new file mode 100644 index 0000000..b0f8a8f --- /dev/null +++ b/vcp/models/__init__.py @@ -0,0 +1,7 @@ +from . import vcp_platform +from . import vcp_branch +from . import vcp_repository +from . import vcp_request +from . import vcp_review +from . import vcp_comment +from . import res_partner diff --git a/vcp/models/res_partner.py b/vcp/models/res_partner.py new file mode 100644 index 0000000..b2794bf --- /dev/null +++ b/vcp/models/res_partner.py @@ -0,0 +1,68 @@ +# Copyright 2026 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +from odoo import api, fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + vcp_merged_requests = fields.Integer( + compute="_compute_vcp_contributions", + string="Merged Requests", + prefetch=False, + ) + vcp_created_requests = fields.Integer( + compute="_compute_vcp_contributions", + string="Created Requests", + prefetch=False, + ) + vcp_comments = fields.Integer( + compute="_compute_vcp_contributions", string="Comments", prefetch=False + ) + vcp_reviews = fields.Integer( + compute="_compute_vcp_contributions", string="Reviews", prefetch=False + ) + + @api.depends() + def _compute_vcp_contributions(self): + self.filtered(lambda p: p.github_user)._compute_vcp_contributions_field( + "partner_id" + ) + self.filtered(lambda p: not p.github_user)._compute_vcp_contributions_field( + "organization_id" + ) + + @api.model + def _get_contributors_field_map(self): + return { + "vcp_merged_requests": "merged_requests", + "vcp_created_requests": "created_requests", + "vcp_comments": "comments", + "vcp_reviews": "reviews", + } + + def _compute_vcp_contributions_field(self, field): + today = fields.Date.today() + start, end = self.env["vcp.platform"]._get_dates(today.year, today.month, "MAT") + data = ( + self.env["vcp.platform"] + .search([]) + ._generate_data( + start=start, end=end, field=field, kind="user", extra_domain=[] + ) + ) + field_map = self._get_contributors_field_map() + for partner in self: + partner.update( + {key: data[partner.id].get(field_map[key], 0) for key in field_map} + ) + + def _get_contributor_url(self): + if self.is_published and self.website_url: + return self.website_url + return False + + def _get_contributors_name(self, kind, **kwargs): + return self.name diff --git a/vcp/models/vcp_branch.py b/vcp/models/vcp_branch.py new file mode 100644 index 0000000..023803a --- /dev/null +++ b/vcp/models/vcp_branch.py @@ -0,0 +1,19 @@ +# Copyright 2026 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class VcpBranch(models.Model): + _name = "vcp.branch" + _description = "Branch" + + name = fields.Char(required=True) + platform_id = fields.Many2one( + comodel_name="vcp.platform", + string="Platform", + required=True, + ) + _sql_constraints = [ + ("name_uniq", "unique(name, platform_id)", "Branch name must be unique.") + ] diff --git a/vcp/models/vcp_comment.py b/vcp/models/vcp_comment.py new file mode 100644 index 0000000..31ffcd7 --- /dev/null +++ b/vcp/models/vcp_comment.py @@ -0,0 +1,36 @@ +# Copyright 2026 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class VcpComment(models.Model): + _name = "vcp.comment" + _description = "Comment" + + external_id = fields.Char(readonly=True, required=True, index=True) + body = fields.Html(readonly=True) + partner_id = fields.Many2one( + comodel_name="res.partner", + readonly=True, + ) + organization_id = fields.Many2one( + related="request_id.organization_id", + readonly=True, + store=True, + ) + repository_id = fields.Many2one( + related="request_id.repository_id", + readonly=True, + store=True, + ) + created_at = fields.Datetime(readonly=True) + updated_at = fields.Datetime(readonly=True) + request_id = fields.Many2one( + comodel_name="vcp.request", + string="Request", + readonly=True, + ) + _sql_constraints = [ + ("external_id_uniq", "unique(external_id)", "External ID must be unique.") + ] diff --git a/vcp/models/vcp_platform.py b/vcp/models/vcp_platform.py new file mode 100644 index 0000000..bb68359 --- /dev/null +++ b/vcp/models/vcp_platform.py @@ -0,0 +1,219 @@ +# Copyright 2026 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import logging +from collections import defaultdict +from datetime import datetime + +from dateutil.relativedelta import relativedelta + +from odoo import fields, models, tools + +_logger = logging.getLogger(__name__) + + +class VCPPlatform(models.Model): + """ + This model should define how to interact with a Version Control Platform + (VCP) such as GitHub, GitLab, etc. + 1 platform should correspond to 1 organization/account on the VCP. + """ + + _name = "vcp.platform" + _description = "VCP Platform" + + name = fields.Char(required=True) + description = fields.Char(readonly=True) + short_description = fields.Char(readonly=True) + last_update = fields.Datetime(readonly=True) + active = fields.Boolean(default=True) + update_interval_days = fields.Integer(default=3) + image_1920 = fields.Image() + branch_ids = fields.One2many( + "vcp.branch", + inverse_name="platform_id", + ) + image_128 = fields.Image( + max_width=128, + max_height=128, + store=True, + related="image_1920", + string="Image 128", + ) + image_64 = fields.Image( + max_width=64, max_height=64, store=True, related="image_1920", string="Image 64" + ) + kind = fields.Selection([]) + key_ids = fields.One2many( + comodel_name="vcp.platform.key", + inverse_name="platform_id", + string="API Keys", + ) + repository_ids = fields.One2many( + "vcp.repository", + inverse_name="platform_id", + ) + + def update_information(self): + self.ensure_one() + getattr(self, f"_update_information_{self.kind}")() + self.last_update = fields.Datetime.now() + + def _cron_update_platforms(self): + for organization in self.search([]): + try: + organization.update_information() + except Exception as e: + _logger.error( + "Error updating organization %s: %s", organization.name, str(e) + ) + + @tools.ormcache("self.id", "name") + def _get_branch(self, name): + self.ensure_one() + branch = self.env["vcp.branch"].search( + [("platform_id", "=", self.id), ("name", "=", name)], + limit=1, + ) + if not branch: + branch = ( + self.env["vcp.branch"] + .sudo() + .create( + { + "platform_id": self.id, + "name": name, + } + ) + ) + return branch.id + + def _get_merged_domain(self, start, end, **values): + return [ + ("repository_id.platform_id", "in", self.ids), + ("is_merged", "=", True), + ("closed_at", ">=", start), + ("closed_at", "<", end), + ] + + def _get_created_domain(self, start, end, **values): + return [ + ("repository_id.platform_id", "in", self.ids), + ("created_at", ">=", start), + ("created_at", "<", end), + ] + + def _get_comments_domain(self, start, end, **values): + return [ + ("request_id.repository_id.platform_id", "in", self.ids), + ("created_at", ">=", start), + ("created_at", "<", end), + ] + + def _get_reviews_domain(self, start, end, **values): + return [ + ("request_id.repository_id.platform_id", "in", self.ids), + ("submitted_at", ">=", start), + ("submitted_at", "<", end), + ] + + def _get_default_data(self, start, end, field, kind, **values): + return { + "name": "", + "github_name": "", + "created_requests": 0, + "merged_requests": 0, + "comments": 0, + "reviews": 0, + "developers": 0, + } + + def _generate_data(self, start, end, field, kind, extra_domain=None, **values): + if extra_domain is None: + extra_domain = [] + default_dict = self._get_default_data(start, end, field, kind, **values) + data = defaultdict(lambda: default_dict.copy()) + if not field: + return data + for merged in ( + self.env["vcp.request"] + .sudo() + .read_group( + self._get_merged_domain(start, end, **values) + + extra_domain + + [(field, "!=", False)], + [field], + [field], + ) + ): + data[merged[field][0]]["merged_requests"] = merged[f"{field}_count"] + for pr in ( + self.env["vcp.request"] + .sudo() + .read_group( + self._get_created_domain(start, end, **values) + + extra_domain + + [(field, "!=", False)], + [field, "partner_id:count_distinct"] + if field != "partner_id" + else [field], + [field], + ) + ): + data[pr[field][0]]["created_requests"] = pr[f"{field}_count"] + if field != "partner_id": + data[pr[field][0]]["developers"] = pr["partner_id"] + for comment in ( + self.env["vcp.comment"] + .sudo() + .read_group( + self._get_comments_domain(start, end, **values) + + extra_domain + + [(field, "!=", False)], + [field], + [field], + ) + ): + data[comment[field][0]]["comments"] = comment[f"{field}_count"] + for review in ( + self.env["vcp.review"] + .sudo() + .read_group( + self._get_reviews_domain(start, end, **values) + + extra_domain + + [(field, "!=", False)], + [field], + [field], + ) + ): + data[review[field][0]]["reviews"] = review[f"{field}_count"] + return data + + def _get_dates(self, year, month, period, **values): + if month == 12: + end = datetime(year + 1, 1, 1, 0, 0, 0) + else: + end = datetime(year, month + 1, 1, 0, 0, 0) + if period == "YTD": + start = datetime(year, 1, 1, 0, 0, 0) + elif period == "MAT": + start = end - relativedelta(years=1) + else: + start = datetime(year, month, 1, 0, 0, 0) + return start, end + + +class VcpPlatformKey(models.Model): + _name = "vcp.platform.key" + _description = "VCP Platform API Key" # TODO + + platform_id = fields.Many2one( + comodel_name="vcp.platform", + string="Platform", + required=True, + ondelete="cascade", + ) + name = fields.Char(required=True) + + _sql_constraints = [ + ("name_uniq", "unique(name, platform_id)", "API Key must be unique.") + ] diff --git a/vcp/models/vcp_repository.py b/vcp/models/vcp_repository.py new file mode 100644 index 0000000..7778659 --- /dev/null +++ b/vcp/models/vcp_repository.py @@ -0,0 +1,47 @@ +# Copyright 2026 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class VcpRepository(models.Model): + _name = "vcp.repository" + _description = "Repository" + + name = fields.Char(required=True, index=True) + description = fields.Char(readonly=True) + platform_id = fields.Many2one( + comodel_name="vcp.platform", + required=True, + ) + created_at = fields.Datetime(readonly=True) + stargazers_count = fields.Integer(readonly=True) + fork_count = fields.Integer(readonly=True) + watchers_count = fields.Integer(readonly=True) + from_date = fields.Datetime(readonly=True, required=True) + request_ids = fields.One2many("vcp.request", inverse_name="repository_id") + request_count = fields.Integer(compute="_compute_request_count") + active = fields.Boolean(default=True) + + @api.depends("request_ids") + def _compute_request_count(self): + for record in self: + record.request_count = len(record.request_ids) + + def force_update_information(self): + self.update_information(update_interval_days=365) + + def update_information(self, update_interval_days=None): + self.ensure_one() + getattr(self, f"_update_information_{self.platform_id.kind}")( + update_interval_days=update_interval_days + ) + + def _cron_update_repositories(self, limit=1): + repositories = self.search([], limit=limit, order="from_date ASC") + for repository in repositories: + repository.update_information() + + def _get_repository_url(self): + self.ensure_one() + return False diff --git a/vcp/models/vcp_request.py b/vcp/models/vcp_request.py new file mode 100644 index 0000000..f5855b2 --- /dev/null +++ b/vcp/models/vcp_request.py @@ -0,0 +1,68 @@ +# Copyright 2026 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models, tools + + +class VcpRequest(models.Model): + _name = "vcp.request" + _description = "Code Request" + + external_id = fields.Char(string="Externa ID", readonly=True, index=True) + name = fields.Char(readonly=True) + partner_id = fields.Many2one( + comodel_name="res.partner", + string="Contributor", + readonly=True, + ) + repository_id = fields.Many2one( + comodel_name="vcp.repository", + readonly=True, + ondelete="cascade", + ) + branch_id = fields.Many2one( + comodel_name="vcp.branch", + readonly=True, + ondelete="restrict", + ) + organization_id = fields.Many2one( + comodel_name="res.partner", + readonly=True, + ) + url = fields.Char(readonly=True) + state = fields.Char(readonly=True) + is_merged = fields.Boolean(readonly=True) + created_at = fields.Datetime(readonly=True) + updated_at = fields.Datetime(readonly=True) + closed_at = fields.Datetime(readonly=True) + number = fields.Integer(readonly=True) + label_ids = fields.Many2many( + comodel_name="vcp.request.label", + string="Labels", + readonly=True, + ) + commits = fields.Integer(readonly=True) + additions = fields.Integer(readonly=True) + deletions = fields.Integer(readonly=True) + total_comments = fields.Integer(readonly=True) + review_comments = fields.Integer(readonly=True) + + _sql_constraints = [ + ("external_id_uniq", "unique(external_id)", "External ID must be unique.") + ] + + +class VcpRequestLabel(models.Model): + _name = "vcp.request.label" + _description = "Vcp Request Label" + + name = fields.Char(required=True) + + _sql_constraints = [("name_uniq", "unique(name)", "Label name must be unique.")] + + @tools.ormcache("name") + def _get_label(self, name): + label = self.search([("name", "=", name)], limit=1) + if not label: + label = self.sudo().create({"name": name}) + return label.id diff --git a/vcp/models/vcp_review.py b/vcp/models/vcp_review.py new file mode 100644 index 0000000..c81ba05 --- /dev/null +++ b/vcp/models/vcp_review.py @@ -0,0 +1,38 @@ +# Copyright 2026 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class VcpReview(models.Model): + _name = "vcp.review" + _description = "Review" # TODO + + external_id = fields.Char(readonly=True, required=True, index=True) + body = fields.Html(readonly=True) + state = fields.Char(readonly=True) + partner_id = fields.Many2one("res.partner", readonly=True) + submitted_at = fields.Datetime(readonly=True) + repository_id = fields.Many2one( + related="request_id.repository_id", + readonly=True, + store=True, + ) + request_id = fields.Many2one( + "vcp.request", + readonly=True, + ) + organization_id = fields.Many2one( + related="request_id.organization_id", + readonly=True, + store=True, + ) + platform_id = fields.Many2one( + related="request_id.repository_id.platform_id", + readonly=True, + store=True, + ) + + _sql_constraints = [ + ("external_id_uniq", "unique(external_id)", "External ID must be unique.") + ] diff --git a/vcp/pyproject.toml b/vcp/pyproject.toml new file mode 100644 index 0000000..4231d0c --- /dev/null +++ b/vcp/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/vcp/readme/CONTEXT.md b/vcp/readme/CONTEXT.md new file mode 100644 index 0000000..1c22f75 --- /dev/null +++ b/vcp/readme/CONTEXT.md @@ -0,0 +1,3 @@ +The aim of this module is to allow any community to import data from a version control system. + +The system should be done in a way that is agnostic to the system and the connections are handled directly by specific modules. diff --git a/vcp/readme/CONTRIBUTORS.md b/vcp/readme/CONTRIBUTORS.md new file mode 100644 index 0000000..579d94d --- /dev/null +++ b/vcp/readme/CONTRIBUTORS.md @@ -0,0 +1,5 @@ +- [Dixmit](https://dixmit.com) + - Enric Tobella + +- [Akretion](https://akretion.com) + - Sebastien Beau diff --git a/vcp/readme/DESCRIPTION.md b/vcp/readme/DESCRIPTION.md new file mode 100644 index 0000000..f05f973 --- /dev/null +++ b/vcp/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Creates a set of modules used for handling a version control patform. diff --git a/vcp/security/ir.model.access.csv b/vcp/security/ir.model.access.csv new file mode 100644 index 0000000..34d58cd --- /dev/null +++ b/vcp/security/ir.model.access.csv @@ -0,0 +1,11 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +access_vcp_platform,Access Platform,model_vcp_platform,base.group_user,1,0,0,0 +access_vcp_platform_portal,Access Platform from Portal,model_vcp_platform,base.group_portal,1,0,0,0 +manage_vcp_platform,Manage Platform,model_vcp_platform,base.group_system,1,1,1,0 +manage_vcp_platform_key,Manage Platform Keys,model_vcp_platform_key,base.group_system,1,1,1,1 +access_branch,Access Branch,model_vcp_branch,base.group_user,1,0,0,0 +access_repository,Access Repository,model_vcp_repository,base.group_user,1,0,0,0 +access_request,Access Pull Requests,model_vcp_request,base.group_user,1,0,0,0 +access_request_label,Access Pull Requests Labels,model_vcp_request_label,base.group_user,1,0,0,0 +access_review,Access Reviews,model_vcp_review,base.group_user,1,0,0,0 +access_comment,Access Comments,model_vcp_comment,base.group_user,1,0,0,0 diff --git a/vcp/static/description/icon.png b/vcp/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1fece979a0ac106449124efb87406041beee51da GIT binary patch literal 2789 zcmVpF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H13UWzA zK~#90(uV z@%xvv)?WKt>z?er_Fn4{Gvm7q@of|MwxOC)%Dew)hCAphky1=&Nf|<+VZoxi^H0;; zCz@bFtR~TU28u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eg6EGn!~J?*=fQB!p>v|tca+v+F<>2OYrDjl8ASJCv>PKK zNN}fXT5!=f&CpD7xa1sLSM^6Em9bY{f^eUe&I1$BCRed}^KJ%SNvsLDW(GZ=*q5;Y zAcC2TZ5<2S!6HbEmrGah=hiVjIfvB-0YD3f9|oYso!B8iu}ummEPIn~tFm|1d?Lem z)G~sRJSM`ZYO`I8_zf2Ucah()CK(N1`xFG;HT-*i-x5E_|Nj?nIJmbP=R=# zGdFauDPs)Hf6y5ns0EQJv=y*405TXX2D2eSXI^*^CYvyWhn+iEq9p3E+nJwlwtd$W zEDeCJ>v30hH78tP#tv&V82Cz^A9D_7%lZWYtJeS#zoSI3x%qs(?!5q=7E?%Mx@p4< zEDeC7>&N5CLnBJUW(zH#bZTB1%y)y#tm%3^fP@_-Ca@>$_g{@wt4!T8C5s9BaI&ho`Aey)7XbJ$ z4Kx4Hb-lKF+qU$Zh7B;GUyfEbHV(D9To(Yi55PzgLq`BSP*GD;Th-kB<;1WXh2<9_ zMrgg}nq1Pf70i4SfQlF@I)J?ZHiiR%7bfyokHr5h0Fn6g(o3^lMDvKKKmx;p+3#a+ rS=ih>A#L~Z@T~;k{|VpuugCujHAmnUkNyne00000NkvXXu0mjfjuIJ8 literal 0 HcmV?d00001 diff --git a/vcp/static/description/icon.svg b/vcp/static/description/icon.svg new file mode 100644 index 0000000..261d62c --- /dev/null +++ b/vcp/static/description/icon.svg @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + diff --git a/vcp/static/description/index.html b/vcp/static/description/index.html new file mode 100644 index 0000000..19cb1b8 --- /dev/null +++ b/vcp/static/description/index.html @@ -0,0 +1,438 @@ + + + + + +Vcp + + + +
+

Vcp

+ + +

Beta License: AGPL-3 OCA/version-control-platform Translate me on Weblate Try me on Runboat

+

Creates a set of modules used for handling a version control patform.

+

Table of contents

+ +
+

Use Cases / Context

+

The aim of this module is to allow any community to import data from a +version control system.

+

The system should be done in a way that is agnostic to the system and +the connections are handled directly by specific modules.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Dixmit
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/version-control-platform project on GitHub.

+

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

+
+
+
+ + diff --git a/vcp/static/src/components/popover_tooltip/popover_tooltip.esm.js b/vcp/static/src/components/popover_tooltip/popover_tooltip.esm.js new file mode 100644 index 0000000..0ad6447 --- /dev/null +++ b/vcp/static/src/components/popover_tooltip/popover_tooltip.esm.js @@ -0,0 +1,8 @@ +import {Component} from "@odoo/owl"; + +export class PopoverTooltip extends Component { + static template = "vcp.PopoverTooltip"; + static props = { + content: String, + }; +} diff --git a/vcp/static/src/components/popover_tooltip/popover_tooltip.xml b/vcp/static/src/components/popover_tooltip/popover_tooltip.xml new file mode 100644 index 0000000..268ffe9 --- /dev/null +++ b/vcp/static/src/components/popover_tooltip/popover_tooltip.xml @@ -0,0 +1,7 @@ + + +
+ +
+
+
diff --git a/vcp/static/src/components/vcp_render/vcp_render.esm.js b/vcp/static/src/components/vcp_render/vcp_render.esm.js new file mode 100644 index 0000000..2fe5c78 --- /dev/null +++ b/vcp/static/src/components/vcp_render/vcp_render.esm.js @@ -0,0 +1,122 @@ +import {Component, markup, onMounted, useState} from "@odoo/owl"; +import {Dropdown} from "@web/core/dropdown/dropdown"; +import {DropdownItem} from "@web/core/dropdown/dropdown_item"; +import {PopoverTooltip} from "../popover_tooltip/popover_tooltip.esm"; +import {formatFloat} from "@web/core/utils/numbers"; +import {registry} from "@web/core/registry"; +import {renderToString} from "@web/core/utils/render"; +import {rpc} from "@web/core/network/rpc"; +import {usePopover} from "@web/core/popover/popover_hook"; + +export class VcpRender extends Component { + static template = "vcp.VcpRender"; + setup() { + const year = new Date().getFullYear(); + const month = new Date().getMonth() + 1; + this.state = useState({ + sort: { + contributors: "index", + organizations: "merged_pull_requests", + repositories: "merged_pull_requests", + }, + columns: {}, + period: "YTD", + contributors: [], + organizations: [], + repositories: [], + year: month === 1 ? year - 1 : year, + month: (month === 1 ? 12 : month - 1).toString(), + kind: "contributors", + }); + onMounted(this.fetchData.bind(this)); + this.popover = usePopover(PopoverTooltip); + } + selectPeriod(period) { + this.state.period = period; + this.fetchData(); + } + initColumnTooltip(ev, column) { + this.popover.open(ev.currentTarget, { + content: markup(column.tooltip), + }); + } + initDateTooltip(ev) { + this.popover.open(ev.currentTarget, { + content: markup(renderToString("vcp.DateSelectionTooltip")), + }); + } + async fetchData() { + const data = await rpc("/vcp-fetch", this.getParameters()); + if (this.state.kind === "contributors") { + this.state.contributors = data.data; + } else if (this.state.kind === "organizations") { + this.state.organizations = data.data; + } else if (this.state.kind === "repositories") { + this.state.repositories = data.data; + } + this.state.columns = data.columns; + return data; + } + getParameters() { + return { + year: parseInt(this.state.year, 10), + month: parseInt(this.state.month, 10), + vcp_id: this.props.vcp, + kind: this.state.kind, + period: this.state.period, + }; + } + get rowIds() { + if (this.state.kind === "contributors") { + return Object.keys(this.state.contributors).sort( + (a, b) => + this.state.contributors[b][this.state.sort.contributors] - + this.state.contributors[a][this.state.sort.contributors] + ); + } else if (this.state.kind === "organizations") { + return Object.keys(this.state.organizations).sort( + (a, b) => + this.state.organizations[b][this.state.sort.organizations] - + this.state.organizations[a][this.state.sort.organizations] + ); + } else if (this.state.kind === "repositories") { + return Object.keys(this.state.repositories).sort( + (a, b) => + this.state.repositories[b][this.state.sort.repositories] - + this.state.repositories[a][this.state.sort.repositories] + ); + } + return []; + } + getRowData(row_id) { + if (this.state.kind === "organizations") { + return this.state.organizations[row_id]; + } + if (this.state.kind === "repositories") { + return this.state.repositories[row_id]; + } + if (this.state.kind === "contributors") { + return this.state.contributors[row_id]; + } + return {}; + } + formatFloat(value, digits) { + return formatFloat(value, {digits: [digits, digits]}); + } + setKind(kind) { + this.state.kind = kind; + this.fetchData(); + } + sortBy(field) { + this.state.sort[this.state.kind] = field; + } +} + +VcpRender.props = { + vcp: Number, +}; +VcpRender.components = { + Dropdown, + DropdownItem, +}; +registry.category("public_components").add("vcp.VcpRender", VcpRender); diff --git a/vcp/static/src/components/vcp_render/vcp_render.scss b/vcp/static/src/components/vcp_render/vcp_render.scss new file mode 100644 index 0000000..7e556a6 --- /dev/null +++ b/vcp/static/src/components/vcp_render/vcp_render.scss @@ -0,0 +1,31 @@ +.o_vcp_render { + .o_vcp_render_table { + .o_vcp_render_table_header { + &.sortable { + cursor: pointer; + } + } + } + .o_input { + input { + display: block; + width: 100%; + padding: 0.375rem 0.75rem; + font-size: 0.875rem; + font-weight: 400; + line-height: 1.5; + color: #212529; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + background-color: white; + background-clip: padding-box; + border: var(--border-width) solid var(--border-color); + border-radius: var(--border-radius); + transition: + background-color 0.05s ease-in-out, + border-color 0.05s ease-in-out, + box-shadow 0.05s ease-in-out; + } + } +} diff --git a/vcp/static/src/components/vcp_render/vcp_render.xml b/vcp/static/src/components/vcp_render/vcp_render.xml new file mode 100644 index 0000000..2c10a84 --- /dev/null +++ b/vcp/static/src/components/vcp_render/vcp_render.xml @@ -0,0 +1,148 @@ + + +
+ Select the period for which you want to see the contributors statistics. + Options are: +
+
    +
  • MTD: Month-To-Date
  • +
  • YTD: Year-To-Date - From January to the selected month
  • +
  • MAT: Moving Annual Total - Last 12 Months
  • +
+
+ +
+

Contributors Statistics

+
+
+ +
+
+ +
+
+ + + + MTD + YTD + MAT + + +
+
+ +
+
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + + +
+
+
+ +
diff --git a/vcp/static/tests/tours/portal.esm.js b/vcp/static/tests/tours/portal.esm.js new file mode 100644 index 0000000..c30087f --- /dev/null +++ b/vcp/static/tests/tours/portal.esm.js @@ -0,0 +1,111 @@ +import {registry} from "@web/core/registry"; + +registry.category("web_tour.tours").add("portal_load_contributors_github", { + url: "/my", + steps: () => [ + { + content: "Check portal is loaded and Find Contributors menu", + trigger: 'a[href*="/vcp"]:contains("Virtual Control Platforms"):first', + run: "click", + expectUnloadPage: true, + }, + { + content: "Check Contributors Page", + trigger: 'a[href*="/vcp/oca"]:contains("OCA"):first', + run: "click", + expectUnloadPage: true, + }, + { + content: "Check Contributors Page", + trigger: "owl-component", + }, + { + content: "Check Etobella", + trigger: 'span:contains("Enric Tobella"):first', + }, + { + content: "Check LuisDixmit", + trigger: 'span:contains("Luis Rodriguez"):first', + }, + { + content: "Check JordiBForgeFlow", + trigger: 'span:contains("Jordi Ballester"):first', + }, + { + content: "Check Etobella Created Value", + trigger: 'tr:contains("Enric Tobella") td:nth-child(2):contains("1"):first', + }, + { + content: "Check LuisDixmit Created Value", + trigger: + 'tr:contains("Luis Rodriguez") td:nth-child(2):contains("1"):first', + }, + { + content: "Check JordiBForgeFlow Created Value", + trigger: + 'tr:contains("Jordi Ballester") td:nth-child(2):contains("1"):first', + }, + { + content: "Check Etobella Merged Value", + trigger: 'tr:contains("Enric Tobella") td:nth-child(3):contains("1"):first', + }, + { + content: "Check LuisDixmit Merged Value", + trigger: + 'tr:contains("Luis Rodriguez") td:nth-child(3):contains("0"):first', + }, + { + content: "Check JordiBForgeFlow Merged Value", + trigger: + 'tr:contains("Jordi Ballester") td:nth-child(3):contains("0"):first', + }, + { + content: "Change to Repositories", + trigger: ".o_vcp_repositories button", + run: "click", + }, + { + content: "Check Repository", + trigger: 'span:contains("contributors-module"):first', + }, + { + content: "Check Created Requests Value", + trigger: + 'tr:contains("contributors-module") td:nth-child(2):contains("3"):first', + }, + { + content: "Check Merged Requests Value", + trigger: + 'tr:contains("contributors-module") td:nth-child(3):contains("1"):first', + }, + { + content: "Change to Organizations", + trigger: ".o_vcp_organizations button", + run: "click", + }, + { + content: "Check Dixmit", + trigger: 'tr:contains("Dixmit"):first', + }, + { + content: "Check ForgeFlow", + trigger: 'tr:contains("ForgeFlow"):first', + }, + { + content: "Check Dixmit Created Pull Requests Value", + trigger: 'tr:contains("Dixmit") td:nth-child(2):contains("2"):first', + }, + { + content: "Check ForgeFlow Created Pull Requests Value", + trigger: 'tr:contains("ForgeFlow") td:nth-child(2):contains("1"):first', + }, + { + content: "Check Dixmit Merged Pull Requests Value", + trigger: 'tr:contains("Dixmit") td:nth-child(3):contains("1"):first', + }, + { + content: "Check ForgeFlow Merged Pull Requests Value", + trigger: 'tr:contains("ForgeFlow") td:nth-child(3):contains("0"):first', + }, + ], +}); diff --git a/vcp/templates/templates.xml b/vcp/templates/templates.xml new file mode 100644 index 0000000..f1ec432 --- /dev/null +++ b/vcp/templates/templates.xml @@ -0,0 +1,100 @@ + + + + + + + + diff --git a/vcp/tests/__init__.py b/vcp/tests/__init__.py new file mode 100644 index 0000000..8307da4 --- /dev/null +++ b/vcp/tests/__init__.py @@ -0,0 +1 @@ +from . import test_portal diff --git a/vcp/tests/test_portal.py b/vcp/tests/test_portal.py new file mode 100644 index 0000000..fc11101 --- /dev/null +++ b/vcp/tests/test_portal.py @@ -0,0 +1,125 @@ +# Copyright 2026 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from datetime import timedelta + +from odoo.fields import Date +from odoo.tests import tagged + +from odoo.addons.base.tests.common import HttpCaseWithUserDemo, HttpCaseWithUserPortal + + +@tagged("post_install", "-at_install") +class TestUi(HttpCaseWithUserDemo, HttpCaseWithUserPortal): + @classmethod + def setUpClass(cls): + super().setUpClass() + # be sure some expected values are set otherwise homepage may fail + date = Date.today() + date = date - timedelta(days=date.day) + cls.partner_portal.write( + { + "city": "Bayonne", + "company_name": "YourCompany", + "country_id": cls.env.ref("base.us").id, + "phone": "(683)-556-5104", + "street": "858 Lynn Street", + "zip": "07002", + } + ) + platform = cls.env["vcp.platform"].create( + { + "name": "oca", + "short_description": "OCA", + "description": "OCA", + } + ) + repository = cls.env["vcp.repository"].create( + { + "name": "contributors-module", + "description": "OCA/contributors-module", + "platform_id": platform.id, + "from_date": date, + } + ) + user_01 = cls.env["res.partner"].create( + { + "name": "Enric Tobella", + } + ) + user_02 = cls.env["res.partner"].create( + { + "name": "Luis Rodriguez", + } + ) + user_03 = cls.env["res.partner"].create( + { + "name": "Jordi Ballester", + } + ) + org_01 = cls.env["res.partner"].create( + { + "name": "Dixmit", + } + ) + org_02 = cls.env["res.partner"].create( + { + "name": "ForgeFlow", + } + ) + pull_request_01 = cls.env["vcp.request"].create( + { + "external_id": 1, + "name": "Test PR", + "repository_id": repository.id, + "partner_id": user_01.id, + "organization_id": org_01.id, + "created_at": date, + "closed_at": date, + "is_merged": True, + } + ) + cls.env["vcp.request"].create( + { + "external_id": 2, + "name": "Test PR", + "repository_id": repository.id, + "partner_id": user_02.id, + "organization_id": org_01.id, + "created_at": date, + "is_merged": False, + } + ) + cls.env["vcp.request"].create( + { + "external_id": 3, + "name": "Test PR", + "repository_id": repository.id, + "partner_id": user_03.id, + "organization_id": org_02.id, + "created_at": date, + "is_merged": False, + } + ) + cls.env["vcp.review"].create( + { + "external_id": 1, + "body": "Test Review", + "state": "APPROVED", + "request_id": pull_request_01.id, + "partner_id": user_01.id, + "submitted_at": date, + } + ) + cls.env["vcp.comment"].create( + { + "external_id": 1, + "body": "Test Comment", + "request_id": pull_request_01.id, + "partner_id": user_01.id, + "created_at": date, + } + ) + + def test_01_portal_load_tour(self): + self.start_tour("/", "portal_load_contributors_github", login="portal") diff --git a/vcp/views/menu.xml b/vcp/views/menu.xml new file mode 100644 index 0000000..ae210f4 --- /dev/null +++ b/vcp/views/menu.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/vcp/views/vcp_branch.xml b/vcp/views/vcp_branch.xml new file mode 100644 index 0000000..f5b6041 --- /dev/null +++ b/vcp/views/vcp_branch.xml @@ -0,0 +1,27 @@ + + + + + vcp.branch + +
+
+ + + + + + + + + + + vcp.branch + + + + + + + diff --git a/vcp/views/vcp_comment.xml b/vcp/views/vcp_comment.xml new file mode 100644 index 0000000..c43cec9 --- /dev/null +++ b/vcp/views/vcp_comment.xml @@ -0,0 +1,26 @@ + + + + + vcp.comment + +
+
+ + + + + + + + + + vcp.comment + + + + + + + diff --git a/vcp/views/vcp_platform.xml b/vcp/views/vcp_platform.xml new file mode 100644 index 0000000..39c5959 --- /dev/null +++ b/vcp/views/vcp_platform.xml @@ -0,0 +1,83 @@ + + + + + vcp.platform + +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + vcp.platform + + + + + + + + + + vcp.platform + + + + + + + + + Platforms + vcp-platforms + vcp.platform + list,form + [] + {} + + + + Platforms + + + + + diff --git a/vcp/views/vcp_repository.xml b/vcp/views/vcp_repository.xml new file mode 100644 index 0000000..ca431aa --- /dev/null +++ b/vcp/views/vcp_repository.xml @@ -0,0 +1,102 @@ + + + + + vcp.repository + +
+
+
+ +
+ + + + +
+ + + + + +
+
+
+
+ + + vcp.repository + + + + + + + + + + vcp.repository + + + + + + + + + + + + Repositories + vcp-repositories + vcp.repository + list,form + [] + {} + + + + Repositories + + + + +
diff --git a/vcp/views/vcp_request.xml b/vcp/views/vcp_request.xml new file mode 100644 index 0000000..fd7b5ee --- /dev/null +++ b/vcp/views/vcp_request.xml @@ -0,0 +1,92 @@ + + + + + vcp.request + +
+
+ + + + + + + + + + + + + + + + + + + + + + + vcp.request + + + + + + + + + + + + + vcp.request + + + + + + + + + + + + + + Requests + vcp-requests + vcp.request + list,form + [] + {} + + + + Requests + vcp-platform-requests + vcp.request + list,form + [("repository_id", "=", active_id)] + {} + + + + Requests + + + + + diff --git a/vcp/views/vcp_review.xml b/vcp/views/vcp_review.xml new file mode 100644 index 0000000..6c20335 --- /dev/null +++ b/vcp/views/vcp_review.xml @@ -0,0 +1,27 @@ + + + + + vcp.review + +
+
+ + + + + + + + + + + vcp.review + + + + + + + From a3bf5228b9e65e3eb2b9ccea159201620e224e1e Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Sat, 24 Jan 2026 10:41:35 +0100 Subject: [PATCH 02/11] [ADD] vcp_github --- requirements.txt | 2 + vcp_github/README.rst | 211 +++++++++ vcp_github/__init__.py | 1 + vcp_github/__manifest__.py | 19 + vcp_github/models/__init__.py | 3 + vcp_github/models/res_partner.py | 123 +++++ vcp_github/models/vcp_platform.py | 79 ++++ vcp_github/models/vcp_repository.py | 193 ++++++++ vcp_github/pyproject.toml | 3 + vcp_github/readme/CONFIGURE.md | 10 + vcp_github/readme/CONTEXT.md | 16 + vcp_github/readme/CONTRIBUTORS.md | 2 + vcp_github/readme/CREDITS.md | 7 + vcp_github/readme/DESCRIPTION.md | 7 + vcp_github/readme/HISTORY.md | 22 + vcp_github/readme/INSTALL.md | 7 + vcp_github/readme/ROADMAP.md | 5 + vcp_github/readme/USAGE.md | 21 + vcp_github/static/description/icon.png | Bin 0 -> 9455 bytes vcp_github/static/description/index.html | 555 +++++++++++++++++++++++ vcp_github/tests/__init__.py | 1 + vcp_github/tests/test_github.py | 114 +++++ 22 files changed, 1401 insertions(+) create mode 100644 requirements.txt create mode 100644 vcp_github/README.rst create mode 100644 vcp_github/__init__.py create mode 100644 vcp_github/__manifest__.py create mode 100644 vcp_github/models/__init__.py create mode 100644 vcp_github/models/res_partner.py create mode 100644 vcp_github/models/vcp_platform.py create mode 100644 vcp_github/models/vcp_repository.py create mode 100644 vcp_github/pyproject.toml create mode 100644 vcp_github/readme/CONFIGURE.md create mode 100644 vcp_github/readme/CONTEXT.md create mode 100644 vcp_github/readme/CONTRIBUTORS.md create mode 100644 vcp_github/readme/CREDITS.md create mode 100644 vcp_github/readme/DESCRIPTION.md create mode 100644 vcp_github/readme/HISTORY.md create mode 100644 vcp_github/readme/INSTALL.md create mode 100644 vcp_github/readme/ROADMAP.md create mode 100644 vcp_github/readme/USAGE.md create mode 100644 vcp_github/static/description/icon.png create mode 100644 vcp_github/static/description/index.html create mode 100644 vcp_github/tests/__init__.py create mode 100644 vcp_github/tests/test_github.py diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f8976b3 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# generated from manifests external_dependencies +github3.py diff --git a/vcp_github/README.rst b/vcp_github/README.rst new file mode 100644 index 0000000..07627b8 --- /dev/null +++ b/vcp_github/README.rst @@ -0,0 +1,211 @@ +========== +Vcp Github +========== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:086596db3dcb4fa7565fc97cf01ccd22449731243622d4587a1f609eab8bc121 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fversion--control--platform-lightgray.png?logo=github + :target: https://github.com/OCA/version-control-platform/tree/18.0/vcp_github + :alt: OCA/version-control-platform +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/version-control-platform-18-0/version-control-platform-18-0-vcp_github + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/version-control-platform&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +[ This file must be max 2-3 paragraphs, and is required. + +The goal of this document is to explain quickly the features of this +module: “what” this module does and “what” it is for. ] + +Example: + +This module extends the functionality of ... to support ... and to allow +users to ... + +**Table of contents** + +.. contents:: + :local: + +Use Cases / Context +=================== + +[ This file is optional but strongly suggested to allow end-users to +evaluate the module's usefulness in their context. ] + +BUSINESS NEED: It should explain the “why” of the module: + +- what is the business requirement that generated the need to develop + this module +- in which context or use cases this module can be useful (practical + examples are welcome!). + +APPROACH: It could also explain the approach to address the mentioned +need. + +USEFUL INFORMATION: It can also inform on related modules: + +- modules it depends on and their features +- other modules that can work well together with this one +- suggested setups where the module is useful (eg: multicompany, + multi-website) + +Installation +============ + +[ This file must only be present if there are very specific installation +instructions, such as installing non-python dependencies. The audience +is systems administrators. ] + +To install this module, you need to: + +1. Do this ... + +Configuration +============= + +[ This file is not always required; it should explain **how to configure +the module before using it**; it is aimed at users with administration +privileges. + +Please be detailed on the path to configuration (eg: do you need to +activate developer mode?), describe step by step configurations and the +use of screenshots is strongly recommended.] + +To configure this module, you need to: + +- Go to *App* > Menu > Menu item +- Activate boolean… > save +- … + +Usage +===== + +[ This file is required and contains the instructions on **“how”** to +use the module for end-users. + +If the module does not have a visible impact on the user interface, just +add the following sentence: + + This module does not impact the user interface. + +If that’s not the case, please make sure that every usage step is +covered and remember that images speak more than words!] + +To use this module, you need to: + +- Go to *App* > Menu > Menu item + + *insert screenshot!* + +- In “Contact” form, add a value to field *xyz* > save + + *insert screenshot!* + +- The value of *xyz* is now displayed in the list view. + + *insert screenshot!* + +Known issues / Roadmap +====================== + +[ Enumerate known caveats and future potential improvements. It is +mostly intended for end-users, and can also help potential new +contributors discovering new features to implement. ] + +- ... + +Changelog +========= + +[ The change log. The goal of this file is to help readers understand +changes between version. The primary audience is end users and +integrators. Purely technical changes such as code refactoring must not +be mentioned here. + +This file may contain ONE level of section titles, underlined with the ~ +(tilde) character. Other section markers are forbidden and will likely +break the structure of the README.rst or other documents where this +fragment is included. ] + +11.0.x.y.z (YYYY-MM-DD) +----------------------- + +- [BREAKING] Breaking changes come first. + (`#70 `__) +- [ADD] New feature. (`#74 `__) +- [FIX] Correct this. (`#71 `__) + +11.0.x.y.z (YYYY-MM-DD) +----------------------- + +- ... + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Dixmit + +Contributors +------------ + +- Firstname Lastname email.address@example.org (optional company website + url) +- Second Person second.person@example.org (optional company website url) + +Other credits +------------- + +[ This file is optional and contains additional credits, other than +authors, contributors, and maintainers. ] + +The development of this module has been financially supported by: + +- Company 1 name +- Company 2 name + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/version-control-platform `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/vcp_github/__init__.py b/vcp_github/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/vcp_github/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/vcp_github/__manifest__.py b/vcp_github/__manifest__.py new file mode 100644 index 0000000..9ddb87a --- /dev/null +++ b/vcp_github/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2026 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Vcp Github", + "summary": """Integrate Virtual Control Platform with Github""", + "version": "18.0.1.0.0", + "license": "AGPL-3", + "author": "Dixmit,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/version-control-platform", + "depends": [ + "vcp", + ], + "external_dependencies": { + "python": ["github3.py"], + }, + "data": [], + "demo": [], +} diff --git a/vcp_github/models/__init__.py b/vcp_github/models/__init__.py new file mode 100644 index 0000000..8fe49b4 --- /dev/null +++ b/vcp_github/models/__init__.py @@ -0,0 +1,3 @@ +from . import vcp_platform +from . import vcp_repository +from . import res_partner diff --git a/vcp_github/models/res_partner.py b/vcp_github/models/res_partner.py new file mode 100644 index 0000000..f46fed1 --- /dev/null +++ b/vcp_github/models/res_partner.py @@ -0,0 +1,123 @@ +# Copyright 2026 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import github3 + +from odoo import fields, models, tools + + +class ResPartner(models.Model): + _inherit = "res.partner" + + github_name = fields.Char( + string="GitHub Username", + help="GitHub username of the contributor or organization", + readonly=True, + ) + github_organization = fields.Boolean( + string="Is GitHub Organization", + help="Check if this partner represents a GitHub organization", + readonly=True, + ) + github_user = fields.Boolean( + string="Is GitHub User", + help="Check if this partner represents a GitHub user", + readonly=True, + ) + + _sql_constraints = [ + ( + "github_name_uniq", + "unique(github_name)", + "The GitHub username must be unique across partners.", + ), + ] + + @tools.ormcache("github_login") + def _get_github_user_id(self, github_login): + partner = self.with_context(active_test=False).search( + [("github_name", "=ilike", github_login)], limit=1 + ) + if not partner: + return False + if not partner.github_user: + partner.github_user = True + return partner.id + + @tools.ormcache("github_login") + def _get_github_organization_id(self, github_login): + partner = self.with_context(active_test=False).search( + [("github_name", "=ilike", github_login)], limit=1 + ) + if not partner: + return False + if not partner.github_organization: + partner.github_organization = True + return partner.id + + def _get_github_user(self, gh, client): + if not gh: + return False + if isinstance(gh, github3.users.User): + github_login = gh.login + else: + github_login = str(gh) + partner = self._get_github_user_id(github_login) + if partner: + return partner + if isinstance(gh, str): + try: + gh = client.user(github_login) + name = gh.name or github_login + except github3.exceptions.NotFoundError: + name = gh + else: + if hasattr(gh, "name"): + name = gh.name or github_login + else: + name = github_login + self.env.registry.clear_cache() + return self.create( + { + "name": name, + "github_name": github_login, + "github_user": True, + } + ).id + + def _get_github_organization(self, gh, client): + if not gh: + return False + partner = self._get_github_organization_id(str(gh)) + if partner: + return partner + self.env.registry.clear_cache() + try: + org = client.organization(str(gh)) + + return self.create( + { + "name": org.name or str(gh), + "github_name": str(gh), + "github_organization": True, + } + ).id + except github3.exceptions.NotFoundError: + user = client.user(str(gh)) + name = user.name or str(gh) + except github3.exceptions.ForbiddenError: + name = str(gh) + return self.create( + { + "name": name, + "github_name": str(gh), + "github_user": True, + "github_organization": True, + } + ).id + + def _get_contributor_url(self): + result = super()._get_contributor_url() + if not result and self.github_name: + return f"https://github.com/{self.github_name}" + return result diff --git a/vcp_github/models/vcp_platform.py b/vcp_github/models/vcp_platform.py new file mode 100644 index 0000000..656128f --- /dev/null +++ b/vcp_github/models/vcp_platform.py @@ -0,0 +1,79 @@ +# Copyright 2026 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import base64 +from datetime import datetime + +import github3 +import requests +from pytz import UTC + +from odoo import fields, models + + +class VcpPlatform(models.Model): + _inherit = "vcp.platform" + + kind = fields.Selection( + selection_add=[("github", "GitHub")], + ondelete={"github": "cascade"}, + ) + + def _get_github_clients(self): + git = [] + for key in self.key_ids: + git.append(github3.login(token=key.name)) + return git + + def _update_information_github(self): + self.ensure_one() + clients = self._get_github_clients() + org = clients[0].organization(self.name) + self.short_description = org.name + self.description = org.description + if org.avatar_url: + response = requests.get(org.avatar_url, timeout=10) + response.raise_for_status() + self.image_1920 = base64.b64encode(response.content) + repos = org.repositories() + for repo in repos: + self._update_github_repository(repo) + self.last_update = fields.Datetime.now() + + def _parse_github_date(self, date): + if not date: + return False + return UTC.normalize( + datetime.fromisoformat(date.replace("Z", "+00:00")) + ).replace(tzinfo=None) + + def _update_github_repository(self, repo): + vals = { + "created_at": self._parse_github_date(repo.created_at), + "stargazers_count": repo.stargazers_count, + "fork_count": repo.forks_count, + "watchers_count": repo.watchers_count, + "description": repo.description, + } + repository = self.env["vcp.repository"].search( + [ + ("name", "=", repo.name), + ("platform_id", "=", self.id), + ], + limit=1, + ) + if not repository: + repository = ( + self.env["vcp.repository"] + .sudo() + .create( + { + "name": repo.name, + "platform_id": self.id, + "from_date": vals.get("created_at"), + **vals, + } + ) + ) + else: + repository.sudo().write(vals) diff --git a/vcp_github/models/vcp_repository.py b/vcp_github/models/vcp_repository.py new file mode 100644 index 0000000..6d1630a --- /dev/null +++ b/vcp_github/models/vcp_repository.py @@ -0,0 +1,193 @@ +# Copyright 2026 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import logging +from datetime import datetime, timedelta + +import github3 +from github3 import pulls +from pytz import UTC + +from odoo import fields, models +from odoo.exceptions import ValidationError + +_logger = logging.getLogger(__name__) + + +class VcpRepository(models.Model): + _inherit = "vcp.repository" + + def _parse_github_pr(self, pr, client): + origin_data = pr.as_dict() + comments_url = pr.comments_url + comments_req = client.session.get(comments_url) + comments = comments_req.json() + while comments_req.links.get("next"): + comments_url = comments_req.links["next"]["url"] + comments_req = client.session.get(comments_url) + comments += comments_req.json() + reviews_url = pr.reviews().url + reviews_req = client.session.get(reviews_url) + reviews = reviews_req.json() + while reviews_req.links.get("next"): + reviews_url = reviews_req.links["next"]["url"] + reviews_req = client.session.get(reviews_url) + reviews += reviews_req.json() + return ( + str(pr.id), + { + "partner_id": self.env["res.partner"]._get_github_user(pr.user, client), + "repository_id": self.id, + "branch_id": self.platform_id._get_branch(pr.base.ref), + "organization_id": self.env["res.partner"]._get_github_organization( + pr.head.repo[0], client + ), + "url": pr.html_url, + "state": pr.state, + "name": pr.title, + "is_merged": any(label["name"] == "merged 🎉" for label in pr.labels) + or pr.is_merged(), + "created_at": self.platform_id._parse_github_date( + origin_data["created_at"] + ), + "closed_at": self.platform_id._parse_github_date( + origin_data["closed_at"] + ), + "number": pr.number, + "updated_at": self.platform_id._parse_github_date( + origin_data["updated_at"] + ), + "label_ids": [fields.Command.clear()] + + [ + fields.Command.link( + self.env["vcp.request.label"]._get_label(label["name"]) + ) + for label in origin_data["labels"] + ], + "commits": origin_data["commits"], + "total_comments": origin_data["comments"], + "review_comments": origin_data["review_comments"], + "additions": origin_data["additions"], + "deletions": origin_data["deletions"], + }, + [ + { + "id": str(c["id"]), + "partner_id": c.get("user") + and self.env["res.partner"]._get_github_user( + c["user"].get("login"), client + ), + "body": c["body"], + "created_at": self.platform_id._parse_github_date(c["created_at"]), + "updated_at": self.platform_id._parse_github_date(c["updated_at"]), + } + for c in comments + ], + [ + { + "id": str(r["id"]), + "partner_id": r.get("user") + and self.env["res.partner"]._get_github_user( + r["user"].get("login"), client + ), + "body": r["body"], + "submitted_at": self.platform_id._parse_github_date( + r.get("submitted_at") + ), + "state": r["state"]["keyword"] + if isinstance(r["state"], dict) + else r["state"], + } + for r in reviews + ], + ) + + def _update_information_github( + self, update_interval_days=None, client_for_search=0 + ): + self.ensure_one() + clients = self.platform_id._get_github_clients() + try: + start = UTC.localize(self.from_date) + end = min( + start + + timedelta( + days=update_interval_days or self.platform_id.update_interval_days + ), + UTC.localize(datetime.now()), + ) + start += timedelta( + days=-1 + ) # Add buffer day to avoid missing PRs on boundary dates + i = client_for_search % len(clients) + for pr in clients[i].search_issues( + f"is:pr repo:{self.platform_id.name}/{self.name} " + f"updated:{start.isoformat()}..{end.isoformat()}" + ): + i = (1 + i) % len(clients) + pr_id, pr_data, comments, reviews = self._parse_github_pr( + clients[i]._instance_or_null( + pulls.PullRequest, + clients[i]._json( + pr.issue._get(pr.issue.pull_request_urls.get("url")), 200 + ), + ), + clients[i], + ) + opr = self.env["vcp.request"].search( + [("external_id", "=", pr_id), ("repository_id", "=", self.id)], + limit=1, + ) + if not opr: + opr = ( + self.env["vcp.request"] + .sudo() + .create({"external_id": pr_id, **pr_data}) + ) + else: + opr.sudo().write(pr_data) + for comment in comments: + comment_id = comment.pop("id") + ocomment = self.env["vcp.comment"].search( + [ + ("external_id", "=", comment_id), + ("repository_id", "=", self.id), + ], + limit=1, + ) + if not ocomment: + self.env["vcp.comment"].sudo().create( + { + "external_id": comment_id, + "request_id": opr.id, + **comment, + } + ) + else: + ocomment.sudo().write(comment) + for review in reviews: + review_id = review.pop("id") + oreview = self.env["vcp.review"].search( + [ + ("external_id", "=", review_id), + ("repository_id", "=", self.id), + ], + limit=1, + ) + if not oreview: + self.env["vcp.review"].sudo().create( + { + "external_id": review_id, + "request_id": opr.id, + **review, + } + ) + else: + oreview.sudo().write(review) + self.sudo().from_date = end.replace(tzinfo=None) + except github3.exceptions.ForbiddenError as e: + _logger.error(e) + rate = clients[i].rate_limit() + reset = fields.Datetime.to_string( + datetime.utcfromtimestamp(rate["resources"]["core"]["reset"]) + ) + raise ValidationError(self.env._(f"Reset on {reset}")) from e diff --git a/vcp_github/pyproject.toml b/vcp_github/pyproject.toml new file mode 100644 index 0000000..4231d0c --- /dev/null +++ b/vcp_github/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/vcp_github/readme/CONFIGURE.md b/vcp_github/readme/CONFIGURE.md new file mode 100644 index 0000000..2fdb0e6 --- /dev/null +++ b/vcp_github/readme/CONFIGURE.md @@ -0,0 +1,10 @@ +[ This file is not always required; it should explain **how to configure the module before using it**; it is aimed at users with administration privileges. + +Please be detailed on the path to configuration (eg: do you need to activate developer mode?), describe step by step configurations and the use of screenshots is strongly recommended.] + + +To configure this module, you need to: + +- Go to *App* > Menu > Menu item +- Activate boolean… > save +- … diff --git a/vcp_github/readme/CONTEXT.md b/vcp_github/readme/CONTEXT.md new file mode 100644 index 0000000..096235a --- /dev/null +++ b/vcp_github/readme/CONTEXT.md @@ -0,0 +1,16 @@ +[ This file is optional but strongly suggested to allow end-users to evaluate the +module's usefulness in their context. ] + +BUSINESS NEED: +It should explain the “why” of the module: +- what is the business requirement that generated the need to develop this module +- in which context or use cases this module can be useful (practical examples are welcome!). + +APPROACH: +It could also explain the approach to address the mentioned need. + +USEFUL INFORMATION: +It can also inform on related modules: +- modules it depends on and their features +- other modules that can work well together with this one +- suggested setups where the module is useful (eg: multicompany, multi-website) diff --git a/vcp_github/readme/CONTRIBUTORS.md b/vcp_github/readme/CONTRIBUTORS.md new file mode 100644 index 0000000..7be72fb --- /dev/null +++ b/vcp_github/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Firstname Lastname (optional company website url) +- Second Person (optional company website url) diff --git a/vcp_github/readme/CREDITS.md b/vcp_github/readme/CREDITS.md new file mode 100644 index 0000000..9c2b025 --- /dev/null +++ b/vcp_github/readme/CREDITS.md @@ -0,0 +1,7 @@ +[ This file is optional and contains additional credits, other than + authors, contributors, and maintainers. ] + +The development of this module has been financially supported by: + +- Company 1 name +- Company 2 name diff --git a/vcp_github/readme/DESCRIPTION.md b/vcp_github/readme/DESCRIPTION.md new file mode 100644 index 0000000..2371a14 --- /dev/null +++ b/vcp_github/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +[ This file must be max 2-3 paragraphs, and is required. + +The goal of this document is to explain quickly the features of this module: “what” this module does and “what” it is for. ] + +Example: + +This module extends the functionality of ... to support ... and to allow users to ... diff --git a/vcp_github/readme/HISTORY.md b/vcp_github/readme/HISTORY.md new file mode 100644 index 0000000..a6daf58 --- /dev/null +++ b/vcp_github/readme/HISTORY.md @@ -0,0 +1,22 @@ +[ The change log. The goal of this file is to help readers + understand changes between version. The primary audience is + end users and integrators. Purely technical changes such as + code refactoring must not be mentioned here. + + This file may contain ONE level of section titles, underlined + with the ~ (tilde) character. Other section markers are + forbidden and will likely break the structure of the README.rst + or other documents where this fragment is included. ] + +## 11.0.x.y.z (YYYY-MM-DD) + +- [BREAKING] Breaking changes come first. + ([#70](https://github.com/OCA/repo/issues/70)) +- [ADD] New feature. + ([#74](https://github.com/OCA/repo/issues/74)) +- [FIX] Correct this. + ([#71](https://github.com/OCA/repo/issues/71)) + +## 11.0.x.y.z (YYYY-MM-DD) + +- ... diff --git a/vcp_github/readme/INSTALL.md b/vcp_github/readme/INSTALL.md new file mode 100644 index 0000000..77b98e7 --- /dev/null +++ b/vcp_github/readme/INSTALL.md @@ -0,0 +1,7 @@ +[ This file must only be present if there are very specific + installation instructions, such as installing non-python + dependencies. The audience is systems administrators. ] + +To install this module, you need to: + +1. Do this ... diff --git a/vcp_github/readme/ROADMAP.md b/vcp_github/readme/ROADMAP.md new file mode 100644 index 0000000..446840c --- /dev/null +++ b/vcp_github/readme/ROADMAP.md @@ -0,0 +1,5 @@ +[ Enumerate known caveats and future potential improvements. + It is mostly intended for end-users, and can also help + potential new contributors discovering new features to implement. ] + +- ... diff --git a/vcp_github/readme/USAGE.md b/vcp_github/readme/USAGE.md new file mode 100644 index 0000000..2cf1275 --- /dev/null +++ b/vcp_github/readme/USAGE.md @@ -0,0 +1,21 @@ +[ This file is required and contains the instructions on **“how”** to use the module for end-users. + +If the module does not have a visible impact on the user interface, just add the following sentence: + +> This module does not impact the user interface. + +If that’s not the case, please make sure that every usage step is covered and remember that images speak more than words!] + +To use this module, you need to: + +- Go to *App* > Menu > Menu item + + *insert screenshot!* + +- In “Contact” form, add a value to field *xyz* > save + + *insert screenshot!* + +- The value of *xyz* is now displayed in the list view. + + *insert screenshot!* diff --git a/vcp_github/static/description/icon.png b/vcp_github/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(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y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/vcp_github/static/description/index.html b/vcp_github/static/description/index.html new file mode 100644 index 0000000..63aa4a5 --- /dev/null +++ b/vcp_github/static/description/index.html @@ -0,0 +1,555 @@ + + + + + +Vcp Github + + + +
+

Vcp Github

+ + +

Beta License: AGPL-3 OCA/version-control-platform Translate me on Weblate Try me on Runboat

+

[ This file must be max 2-3 paragraphs, and is required.

+

The goal of this document is to explain quickly the features of this +module: “what” this module does and “what” it is for. ]

+

Example:

+

This module extends the functionality of … to support … and to allow +users to …

+

Table of contents

+ +
+

Use Cases / Context

+

[ This file is optional but strongly suggested to allow end-users to +evaluate the module’s usefulness in their context. ]

+

BUSINESS NEED: It should explain the “why” of the module:

+
    +
  • what is the business requirement that generated the need to develop +this module
  • +
  • in which context or use cases this module can be useful (practical +examples are welcome!).
  • +
+

APPROACH: It could also explain the approach to address the mentioned +need.

+

USEFUL INFORMATION: It can also inform on related modules:

+
    +
  • modules it depends on and their features
  • +
  • other modules that can work well together with this one
  • +
  • suggested setups where the module is useful (eg: multicompany, +multi-website)
  • +
+
+
+

Installation

+

[ This file must only be present if there are very specific installation +instructions, such as installing non-python dependencies. The audience +is systems administrators. ]

+

To install this module, you need to:

+
    +
  1. Do this …
  2. +
+
+
+

Configuration

+

[ This file is not always required; it should explain how to configure +the module before using it; it is aimed at users with administration +privileges.

+

Please be detailed on the path to configuration (eg: do you need to +activate developer mode?), describe step by step configurations and the +use of screenshots is strongly recommended.]

+

To configure this module, you need to:

+
    +
  • Go to App > Menu > Menu item
  • +
  • Activate boolean… > save
  • +
  • +
+
+
+

Usage

+

[ This file is required and contains the instructions on “how” to +use the module for end-users.

+

If the module does not have a visible impact on the user interface, just +add the following sentence:

+
+This module does not impact the user interface.
+

If that’s not the case, please make sure that every usage step is +covered and remember that images speak more than words!]

+

To use this module, you need to:

+
    +
  • Go to App > Menu > Menu item

    +

    insert screenshot!

    +
  • +
  • In “Contact” form, add a value to field xyz > save

    +

    insert screenshot!

    +
  • +
  • The value of xyz is now displayed in the list view.

    +

    insert screenshot!

    +
  • +
+
+
+

Known issues / Roadmap

+

[ Enumerate known caveats and future potential improvements. It is +mostly intended for end-users, and can also help potential new +contributors discovering new features to implement. ]

+
    +
  • +
+
+
+

Changelog

+

[ The change log. The goal of this file is to help readers understand +changes between version. The primary audience is end users and +integrators. Purely technical changes such as code refactoring must not +be mentioned here.

+

This file may contain ONE level of section titles, underlined with the ~ +(tilde) character. Other section markers are forbidden and will likely +break the structure of the README.rst or other documents where this +fragment is included. ]

+
+

11.0.x.y.z (YYYY-MM-DD)

+
    +
  • [BREAKING] Breaking changes come first. +(#70)
  • +
  • [ADD] New feature. (#74)
  • +
  • [FIX] Correct this. (#71)
  • +
+
+ +
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Dixmit
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

[ This file is optional and contains additional credits, other than +authors, contributors, and maintainers. ]

+

The development of this module has been financially supported by:

+
    +
  • Company 1 name
  • +
  • Company 2 name
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/version-control-platform project on GitHub.

+

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

+
+
+
+ + diff --git a/vcp_github/tests/__init__.py b/vcp_github/tests/__init__.py new file mode 100644 index 0000000..c63e32e --- /dev/null +++ b/vcp_github/tests/__init__.py @@ -0,0 +1 @@ +from . import test_github diff --git a/vcp_github/tests/test_github.py b/vcp_github/tests/test_github.py new file mode 100644 index 0000000..76cd448 --- /dev/null +++ b/vcp_github/tests/test_github.py @@ -0,0 +1,114 @@ +# Copyright 2026 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import base64 +from unittest.mock import MagicMock, patch + +from odoo.fields import Command +from odoo.tests.common import TransactionCase + + +class TestGithub(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.platform = cls.env["vcp.platform"].create( + { + "name": "oca", + "kind": "github", + "key_ids": [ + Command.create({"name": "ghp_exampletoken1234567890abcdef"}) + ], + } + ) + + def test_update_organization_and_logo(self): + base_url = self.env["ir.config_parameter"].sudo().get_param("web.base.url") + with ( + patch("odoo.addons.vcp_github.models.vcp_platform.github3") as mock_github3, + patch( + "odoo.addons.vcp_github.models.vcp_platform.requests.get" + ) as mock_requests_get, + ): + mock_client = MagicMock() + mock_org = MagicMock() + mock_org.name = "Odoo Community Association" + mock_org.avatar_url = f"{base_url}/logo.png" + mock_requests_get.return_value.content = base64.b64decode( + self.env.company.logo + ) + mock_client.organization.return_value = mock_org + mock_github3.login.return_value = mock_client + self.platform.update_information() + self.assertEqual( + self.platform.short_description, "Odoo Community Association" + ) + mock_github3.login.assert_called_once_with( + token="ghp_exampletoken1234567890abcdef" + ) + mock_client.organization.assert_called_once_with("oca") + + def test_update_organization_with_repository(self): + with patch( + "odoo.addons.vcp_github.models.vcp_platform.github3" + ) as mock_github3: + mock_client = MagicMock() + mock_org = MagicMock() + mock_org.name = "Odoo Community Association" + mock_org.avatar_url = False + mock_repo1 = MagicMock() + mock_repo1.name = "server-tools" + mock_repo1.created_at = "2020-01-01T00:00:00Z" + mock_repo2 = MagicMock() + mock_repo2.name = "server-brand" + mock_repo2.created_at = "2021-01-01T10:00:00Z" + mock_org.repositories.return_value = [mock_repo1, mock_repo2] + mock_client.organization.return_value = mock_org + mock_github3.login.return_value = mock_client + self.platform.update_information() + self.assertEqual(len(self.platform.repository_ids), 2) + repo_names = {repo.name for repo in self.platform.repository_ids} + self.assertSetEqual(repo_names, {"server-tools", "server-brand"}) + mock_github3.login.assert_called_once_with( + token="ghp_exampletoken1234567890abcdef" + ) + mock_client.organization.assert_called_once_with("oca") + return self.platform.repository_ids.filtered(lambda r: r.name == "server-tools") + + def test_update_repository(self): + repository = self.test_update_organization_with_repository() + self.assertFalse(repository.request_ids) + with patch( + "odoo.addons.vcp_github.models.vcp_platform.github3.login" + ) as mock_client: + mock_login = MagicMock() + mock_client.return_value = mock_login + mock_login.session.get.return_value = MagicMock( + links={}, + json=lambda: [], + ) + mock_issue_request = MagicMock( + as_dict=lambda: { + "id": 1, + "user": {"login": "contributor1"}, + "base": {"ref": "main"}, + "head": {"repo": [MagicMock()]}, + "html_url": "https://github.com/oca/server-tools/pull/1", + "state": "closed", + "title": "Fix issue", + "labels": [{"name": "merged 🎉"}], + "created_at": "2023-01-01T00:00:00Z", + "updated_at": "2023-01-03T00:00:00Z", + "closed_at": "2023-01-02T00:00:00Z", + "commits": 3, + "comments": 2, + "review_comments": 1, + "additions": 150, + "deletions": 50, + "number": 1, + } + ) + mock_login._instance_or_null.return_value = mock_issue_request + mock_login.search_issues.return_value = [mock_issue_request] + repository.update_information() + self.assertTrue(repository.request_ids) From 210cf912b5e1b4c31937cedc008c29cd12fa4f54 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sun, 25 Jan 2026 00:10:39 +0100 Subject: [PATCH 03/11] [FIX] vcp: set kind field required at platform level. It doesn't makes sense to have a plateform without kind + it makes failing call of update_information AttributeError: 'vcp.platform' object has no attribute '_update_information_False'. Did you mean: '_update_information_github'? --- test-requirements.txt | 1 + vcp/models/vcp_platform.py | 2 +- vcp/tests/models/__init__.py | 1 + vcp/tests/models/vcp_platform.py | 16 ++++++++++++++++ vcp/tests/test_portal.py | 10 ++++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 test-requirements.txt create mode 100644 vcp/tests/models/__init__.py create mode 100644 vcp/tests/models/vcp_platform.py diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..66bc2cb --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo_test_helper diff --git a/vcp/models/vcp_platform.py b/vcp/models/vcp_platform.py index bb68359..8d6e3d7 100644 --- a/vcp/models/vcp_platform.py +++ b/vcp/models/vcp_platform.py @@ -42,7 +42,7 @@ class VCPPlatform(models.Model): image_64 = fields.Image( max_width=64, max_height=64, store=True, related="image_1920", string="Image 64" ) - kind = fields.Selection([]) + kind = fields.Selection([], required=True) key_ids = fields.One2many( comodel_name="vcp.platform.key", inverse_name="platform_id", diff --git a/vcp/tests/models/__init__.py b/vcp/tests/models/__init__.py new file mode 100644 index 0000000..ccba792 --- /dev/null +++ b/vcp/tests/models/__init__.py @@ -0,0 +1 @@ +from . import vcp_platform diff --git a/vcp/tests/models/vcp_platform.py b/vcp/tests/models/vcp_platform.py new file mode 100644 index 0000000..c37936e --- /dev/null +++ b/vcp/tests/models/vcp_platform.py @@ -0,0 +1,16 @@ +# Copyright 2026 GRAP +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import logging + +from odoo import fields, models + +_logger = logging.getLogger(__name__) + + +class VCPPlatform(models.Model): + _inherit = "vcp.platform" + + kind = fields.Selection( + selection_add=[("dummy", "Dummy Value")], + ondelete={"dummy": "cascade"}, + ) diff --git a/vcp/tests/test_portal.py b/vcp/tests/test_portal.py index fc11101..d47ea73 100644 --- a/vcp/tests/test_portal.py +++ b/vcp/tests/test_portal.py @@ -3,6 +3,8 @@ from datetime import timedelta +from odoo_test_helper import FakeModelLoader + from odoo.fields import Date from odoo.tests import tagged @@ -14,6 +16,13 @@ class TestUi(HttpCaseWithUserDemo, HttpCaseWithUserPortal): @classmethod def setUpClass(cls): super().setUpClass() + # Load fake order model + cls.loader = FakeModelLoader(cls.env, cls.__module__) + cls.loader.backup_registry() + from .models.vcp_platform import VCPPlatform + + cls.loader.update_registry((VCPPlatform,)) + # be sure some expected values are set otherwise homepage may fail date = Date.today() date = date - timedelta(days=date.day) @@ -32,6 +41,7 @@ def setUpClass(cls): "name": "oca", "short_description": "OCA", "description": "OCA", + "kind": "dummy", } ) repository = cls.env["vcp.repository"].create( From 08481b4bef93a5b8809c8a1e90590a355b099984 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sun, 25 Jan 2026 00:14:56 +0100 Subject: [PATCH 04/11] [FIX] vcp_github: handle correctly the error, if no API Keys are defined --- vcp_github/models/vcp_platform.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vcp_github/models/vcp_platform.py b/vcp_github/models/vcp_platform.py index 656128f..ddd91c7 100644 --- a/vcp_github/models/vcp_platform.py +++ b/vcp_github/models/vcp_platform.py @@ -8,7 +8,8 @@ import requests from pytz import UTC -from odoo import fields, models +from odoo import _, fields, models +from odoo.exceptions import ValidationError class VcpPlatform(models.Model): @@ -28,6 +29,10 @@ def _get_github_clients(self): def _update_information_github(self): self.ensure_one() clients = self._get_github_clients() + if not clients: + raise ValidationError( + _("No github clients configured. Please enter at least an API Key.") + ) org = clients[0].organization(self.name) self.short_description = org.name self.description = org.description From 553b821b4b136bd33dbbd36182f2acd92671c193 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Sun, 25 Jan 2026 18:56:41 +0100 Subject: [PATCH 05/11] [IMP] vcp: remove dependancy on website --- vcp/__manifest__.py | 2 +- vcp/models/res_partner.py | 2 -- vcp/templates/templates.xml | 50 ++++++++++++++----------------------- 3 files changed, 20 insertions(+), 34 deletions(-) diff --git a/vcp/__manifest__.py b/vcp/__manifest__.py index 2f85b83..54b540f 100644 --- a/vcp/__manifest__.py +++ b/vcp/__manifest__.py @@ -8,7 +8,7 @@ "license": "AGPL-3", "author": "Dixmit,Odoo Community Association (OCA)", "website": "https://github.com/OCA/version-control-platform", - "depends": ["website_partner"], + "depends": ["portal"], "data": [ "security/ir.model.access.csv", "data/ir_cron.xml", diff --git a/vcp/models/res_partner.py b/vcp/models/res_partner.py index b2794bf..cdecce8 100644 --- a/vcp/models/res_partner.py +++ b/vcp/models/res_partner.py @@ -60,8 +60,6 @@ def _compute_vcp_contributions_field(self, field): ) def _get_contributor_url(self): - if self.is_published and self.website_url: - return self.website_url return False def _get_contributors_name(self, kind, **kwargs): diff --git a/vcp/templates/templates.xml b/vcp/templates/templates.xml index f1ec432..080d58e 100644 --- a/vcp/templates/templates.xml +++ b/vcp/templates/templates.xml @@ -64,37 +64,25 @@
-