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] oxigen_maintenance_gitlab #150

Open
wants to merge 3 commits 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
66 changes: 66 additions & 0 deletions oxigen_maintenance_gitlab/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
=========================
Oxigen Maintenance Gitlab
=========================

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

.. |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-oxigensalud%2Fodoo--addons-lightgray.png?logo=github
:target: https://github.com/oxigensalud/odoo-addons/tree/14.0/oxigen_maintenance_gitlab
:alt: oxigensalud/odoo-addons

|badge1| |badge2| |badge3|

Allows to generate Gitlab Issues from a Maintenance request.

**Table of contents**

.. contents::
:local:

Usage
=====

Access a Maintenance requesst and press the button create gitlab.

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

Bugs are tracked on `GitHub Issues <https://github.com/oxigensalud/odoo-addons/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/oxigensalud/odoo-addons/issues/new?body=module:%20oxigen_maintenance_gitlab%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
~~~~~~~

* Dixmit

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

* Dixmit
* Enric Tobella

Maintainers
~~~~~~~~~~~

This module is part of the `oxigensalud/odoo-addons <https://github.com/oxigensalud/odoo-addons/tree/14.0/oxigen_maintenance_gitlab>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions oxigen_maintenance_gitlab/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
23 changes: 23 additions & 0 deletions oxigen_maintenance_gitlab/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2023 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Oxigen Maintenance Gitlab",
"summary": """
Integrate maintenance with gitlab""",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Dixmit",
"website": "https://github.com/oxigensalud/odoo-addons",
"depends": [
"maintenance_project",
],
"external_dependencies": {
"python": ["gitlab"],
},
"data": [
"views/maintenance_request.xml",
"views/project_project.xml",
],
"demo": [],
}
2 changes: 2 additions & 0 deletions oxigen_maintenance_gitlab/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import project_project
from . import maintenance_request
37 changes: 37 additions & 0 deletions oxigen_maintenance_gitlab/models/maintenance_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2023 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from gitlab import Gitlab

from odoo import fields, models


class MaintenanceRequest(models.Model):

_inherit = "maintenance.request"

gitlab_id = fields.Integer(related="project_id.gitlab_id")
gitlab_issue_id = fields.Integer(readonly=True, copy=False)
gitlab_issue_url = fields.Char(readonly=True, copy=False)

def _gitlab_issue_vals(self):
return {
"title": self.name or "",
"description": self.description or "",
}

def send_to_gitlab(self):
self.ensure_one()
if not self.gitlab_id or self.gitlab_issue_id:
return
token = self.env["ir.config_parameter"].sudo().get_param("gitlab.token", False)
if not token:
return
gl = Gitlab(
private_token=token,
url=self.env["ir.config_parameter"].sudo().get_param("gitlab.url", None),
)
gl.auth()
issue = gl.projects.get(self.gitlab_id).issues.create(self._gitlab_issue_vals())
self.gitlab_issue_id = issue.id
self.gitlab_issue_url = issue.web_url
11 changes: 11 additions & 0 deletions oxigen_maintenance_gitlab/models/project_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2023 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ProjectProject(models.Model):

_inherit = "project.project"

gitlab_id = fields.Integer(help="Id of the project for gitlab", copy=False)
6 changes: 6 additions & 0 deletions oxigen_maintenance_gitlab/readme/CONFIGURATION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* Create a Gitlab token
* Add the gitlab token on the parameter `gitlab.token`
* If you are not using the standard gitlab server, you can set it with the parameter `gitlab.url``
* Access Project
* Configure one of them
* Set the Gitlab ID of the project
2 changes: 2 additions & 0 deletions oxigen_maintenance_gitlab/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Dixmit
* Enric Tobella
1 change: 1 addition & 0 deletions oxigen_maintenance_gitlab/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allows to generate Gitlab Issues from a Maintenance request.
1 change: 1 addition & 0 deletions oxigen_maintenance_gitlab/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Access a Maintenance requesst and press the button create gitlab.
Loading
Loading