Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] github_connector_pull_request #110

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions github_connector_pull_request/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
================================
Github Connector - Pull Requests
================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0f150511456d2fcb030be2f3c4a07db9249361d9a6ca48d0d3c26804c8c0accd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Finterface--github-lightgray.png?logo=github
:target: https://github.com/OCA/interface-github/tree/14.0/github_connector_pull_request
:alt: OCA/interface-github
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/interface-github-14-0/interface-github-14-0-github_connector_pull_request
: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/interface-github&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Manage Pull Requests.

**Table of contents**

.. contents::
:local:

Usage
=====

In the Repository form, click on Pull Requests Sync.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/interface-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 <https://github.com/OCA/interface-github/issues/new?body=module:%20github_connector_pull_request%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Aion Tech

Contributors
~~~~~~~~~~~~

* `Aion Tech <https://aiontech.company/>`_:

* Simone Rubino <[email protected]>

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/interface-github <https://github.com/OCA/interface-github/tree/14.0/github_connector_pull_request>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions github_connector_pull_request/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
from . import wizards
21 changes: 21 additions & 0 deletions github_connector_pull_request/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Github Connector - Pull Requests",
"summary": "Manage Pull Requests",
"website": "https://github.com/OCA/interface-github",
"category": "Connector",
"license": "AGPL-3",
"version": "14.0.1.0.0",
"author": "Aion Tech, Odoo Community Association (OCA)",
"depends": [
"github_connector",
],
"data": [
"security/ir.model.access.csv",
"views/github_pull_request_views.xml",
"views/github_repository_views.xml",
"data/ir_cron_data.xml",
],
}
14 changes: 14 additions & 0 deletions github_connector_pull_request/data/ir_cron_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
~ Copyright 2023 Simone Rubino - Aion Tech
~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo noupdate="1">
<record id="ir_cron_sync_pull_requests" model="ir.cron">
<field name="name">Synchronize Pull Requests for all Repositories</field>
<field name="active" eval="False" />
<field name="state">code</field>
<field name="model_id" ref="github_connector.model_github_repository" />
<field name="code">model.cron_sync_pull_request()</field>
</record>
</odoo>
206 changes: 206 additions & 0 deletions github_connector_pull_request/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * github_connector_pull_request
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-26 12:39+0000\n"
"PO-Revision-Date: 2023-09-26 12:39+0000\n"
"Last-Translator: Simone Rubino <[email protected]>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: github_connector_pull_request
#: model_terms:ir.ui.view,arch_db:github_connector_pull_request.view_github_repository_form
msgid ""
"<span class=\"o_stat_text\" attrs=\"{ 'invisible': [ ('pull_request_qty', '&lt;', 2), ], }\">\n"
" Pull Requests\n"
" </span>\n"
" <span class=\"o_stat_text\" attrs=\"{ 'invisible': [ ('pull_request_qty', '&gt;', 1), ], }\">\n"
" Pull Request\n"
" </span>"
msgstr ""

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__base_ref
msgid "Base Ref"
msgstr ""

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__base_url
msgid "Base URL"
msgstr ""

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__github_create_date
msgid "Create Date on Github"
msgstr "Data di creazione in GitHub"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__create_uid
msgid "Created by"
msgstr "Creato da"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__create_date
msgid "Created on"
msgstr "Creato il"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__description
msgid "Description"
msgstr "Descrizione"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__display_name
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_repository__display_name
#: model:ir.model.fields,field_description:github_connector_pull_request.field_wizard_load_github_model__display_name
msgid "Display Name"
msgstr "Nome visualizzato"

#. module: github_connector_pull_request
#: model:ir.model,name:github_connector_pull_request.model_github_pull_request
msgid "GitHub Pull Request"
msgstr "Pull Request di GitHub"

#. module: github_connector_pull_request
#: model_terms:ir.ui.view,arch_db:github_connector_pull_request.github_pull_request_view_form
msgid "Github"
msgstr ""

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__github_id_external
msgid "Github Id"
msgstr "ID in GitHub"

#. module: github_connector_pull_request
#: model:ir.model,name:github_connector_pull_request.model_github_repository
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__repository_id
msgid "Github Repository"
msgstr "Repository in GitHub"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__github_name
msgid "Github Technical Name"
msgstr "Nome tecnico in GitHub"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_wizard_load_github_model__github_type
msgid "Github Type Name"
msgstr "Nome del tipo in GitHub"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__github_url
msgid "Github URL"
msgstr "URL in GitHub"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__head_ref
msgid "Head Ref"
msgstr ""

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__head_url
msgid "Head URL"
msgstr ""

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__id
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_repository__id
#: model:ir.model.fields,field_description:github_connector_pull_request.field_wizard_load_github_model__id
msgid "ID"
msgstr ""

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request____last_update
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_repository____last_update
#: model:ir.model.fields,field_description:github_connector_pull_request.field_wizard_load_github_model____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__github_last_sync_date
msgid "Last Sync Date with Github"
msgstr "Data dell'ultima sincronizzazione con GitHub"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__write_uid
msgid "Last Updated by"
msgstr "Ultimo aggiornamento di"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__write_date
msgid "Last Updated on"
msgstr "Ultimo aggiornamento il"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__github_write_date
msgid "Last Write Date on Github"
msgstr "Data dell'ultima scrittura in GitHub"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__name
msgid "Number"
msgstr "Numero"

#. module: github_connector_pull_request
#: code:addons/github_connector_pull_request/models/pull_request.py:0
#: code:addons/interface-github/github_connector_pull_request/models/pull_request.py:0
#, python-format
msgid "Pull Request %s not found"
msgstr "Pull Request %s non trovata"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_repository__pull_request_qty
#: model:ir.model.fields,field_description:github_connector_pull_request.field_wizard_create_repository__pull_request_qty
msgid "Pull Request Quantity"
msgstr "Numero di Pull Requests"

#. module: github_connector_pull_request
#: model:ir.model.fields.selection,name:github_connector_pull_request.selection__wizard_load_github_model__github_type__pr
msgid "Pull Request URL"
msgstr "Url della Pull Request"

#. module: github_connector_pull_request
#: code:addons/github_connector_pull_request/models/pull_request.py:0
#: code:addons/interface-github/github_connector_pull_request/models/pull_request.py:0
#, python-format
msgid "Pull Request URL %(pr_url)s cannot be parsed"
msgstr "Impossibile processare l'URL %(pr_url)s della Pull Request"

#. module: github_connector_pull_request
#: model:ir.actions.act_window,name:github_connector_pull_request.github_pull_request_action
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_repository__pull_request_ids
#: model:ir.model.fields,field_description:github_connector_pull_request.field_wizard_create_repository__pull_request_ids
msgid "Pull Requests"
msgstr ""

#. module: github_connector_pull_request
#: model_terms:ir.ui.view,arch_db:github_connector_pull_request.view_github_repository_form
msgid "Pull Requests Sync."
msgstr "Sinc. Pull Requests"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__state
msgid "State"
msgstr "Stato"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__title
msgid "Title"
msgstr "Titolo"

#. module: github_connector_pull_request
#: model:ir.model.fields,field_description:github_connector_pull_request.field_github_pull_request__user
msgid "User"
msgstr "Utente"

#. module: github_connector_pull_request
#: model:ir.model,name:github_connector_pull_request.model_wizard_load_github_model
msgid "Wizard Load Github Model"
msgstr "Procedura per caricare modelli di GitHub"
4 changes: 4 additions & 0 deletions github_connector_pull_request/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import github_repository
from . import pull_request
54 changes: 54 additions & 0 deletions github_connector_pull_request/models/github_repository.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2023 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class GithubRepository(models.Model):
_inherit = "github.repository"

pull_request_ids = fields.One2many(
comodel_name="github.pull_request",
inverse_name="repository_id",
string="Pull Requests",
)
pull_request_qty = fields.Integer(
string="Pull Request Quantity",
compute="_compute_pull_request_qty",
store=True,
)

@api.depends("pull_request_ids.repository_id")
def _compute_pull_request_qty(self):
for repository in self:
repository.pull_request_qty = len(repository.pull_request_ids)

def action_github_pull_requests(self):
self.ensure_one()
action = self.env["ir.actions.act_window"]._for_xml_id(

Check warning on line 28 in github_connector_pull_request/models/github_repository.py

View check run for this annotation

Codecov / codecov/patch

github_connector_pull_request/models/github_repository.py#L27-L28

Added lines #L27 - L28 were not covered by tests
"github_connector_pull_request.github_pull_request_action"
)
action["context"] = dict(self.env.context)
action["context"]["search_default_repository_id"] = self.id
return action

Check warning on line 33 in github_connector_pull_request/models/github_repository.py

View check run for this annotation

Codecov / codecov/patch

github_connector_pull_request/models/github_repository.py#L31-L33

Added lines #L31 - L33 were not covered by tests

def button_sync_pull_request(self):
for repository in self.filtered(lambda r: not r.is_ignored):
gh_repo = repository.find_related_github_object()
gh_prs = gh_repo.get_pulls()
for gh_pr in gh_prs:
pull_request = (
self.env["github.pull_request"]
.with_context(
repository_id=repository.id,
)
.get_from_id_or_create(
gh_data=gh_pr,
)
)
pull_request.update_from_github(False)

@api.model
def cron_sync_pull_request(self):
repositories = self.search([])
repositories.button_sync_pull_request()
Loading
Loading