[NEW] Addons dev_github_project_task_connector creation
This commit is contained in:
4
dev_github_project_task_connector/__init__.py
Normal file
4
dev_github_project_task_connector/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
from . import wizard
|
88
dev_github_project_task_connector/__manifest__.py
Normal file
88
dev_github_project_task_connector/__manifest__.py
Normal file
@@ -0,0 +1,88 @@
|
||||
# Copyright 2021 Elabore ()
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
"name": "Github Project Task Connector",
|
||||
"version": "12.0.1.0.0",
|
||||
"author": "Elabore",
|
||||
"maintainer": "False",
|
||||
"website": "False",
|
||||
"license": "AGPL-3",
|
||||
"category": "False",
|
||||
"summary": "Link project task to Github issues",
|
||||
"description": """
|
||||
:image: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
=============================
|
||||
Github Project Task Connector
|
||||
=============================
|
||||
This module provides link functionnalities between project tasks and Github issues:
|
||||
- a user can create an Github issue from a project task
|
||||
- a user can link an existing Github task to a project task
|
||||
- the list of issues linked to the task is displayed with the issues' status
|
||||
|
||||
Installation
|
||||
============
|
||||
Just install Github Project Task Connector, all dependencies will be installed by default.
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
Bugs are tracked on `GitHub Issues
|
||||
<https://github.com/elabore-coop/development-tools/issues>`_. In case of trouble, please
|
||||
check there if your issue has already been reported. If you spotted it first,
|
||||
help us smashing it by providing a detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Images
|
||||
------
|
||||
* Elabore: `Icon <https://elabore.coop/web/image/res.company/1/logo?unique=f3db262>`_.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
* Stéphan Sainléger <https://github.com/stephansainleger>
|
||||
|
||||
Funders
|
||||
-------
|
||||
The development of this module has been financially supported by:
|
||||
* Elabore (https://elabore.coop)
|
||||
* Lokavaluto (https://lokavaluto.fr)
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
This module is maintained by ELABORE.
|
||||
|
||||
""",
|
||||
# any module necessary for this one to work correctly
|
||||
"depends": [
|
||||
"base",
|
||||
"project",
|
||||
],
|
||||
"external_dependencies": {
|
||||
"python": [],
|
||||
},
|
||||
# always loaded
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"wizard/link_issue.xml",
|
||||
"views/project_task.xml",
|
||||
"views/git_issue.xml",
|
||||
"views/git_repository.xml",
|
||||
"views/menus.xml",
|
||||
],
|
||||
# only loaded in demonstration mode
|
||||
"demo": [],
|
||||
"js": [],
|
||||
"css": [],
|
||||
"qweb": [],
|
||||
"installable": True,
|
||||
# Install this module automatically if all dependency have been previously
|
||||
# and independently installed. Used for synergetic or glue modules.
|
||||
"auto_install": False,
|
||||
"application": False,
|
||||
}
|
5
dev_github_project_task_connector/models/__init__.py
Normal file
5
dev_github_project_task_connector/models/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import project_task
|
||||
from . import git_issue
|
||||
from . import git_repo
|
23
dev_github_project_task_connector/models/git_issue.py
Normal file
23
dev_github_project_task_connector/models/git_issue.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class GitIssue(models.Model):
|
||||
_name = "git.issue"
|
||||
_description = "Issue Git"
|
||||
|
||||
name = fields.Char(string="Title", required=True, copy=True)
|
||||
repo = fields.Many2one("git.repo", required=True, copy=True)
|
||||
status = fields.Selection(
|
||||
[
|
||||
("opened", "Opened"),
|
||||
("closed", "Closed"),
|
||||
],
|
||||
required=True,
|
||||
default="opened",
|
||||
copy=False,
|
||||
)
|
||||
url = fields.Char(string="Link", required=True, copy=False)
|
||||
|
||||
task_id = fields.Many2one("project.task", required=True, copy=True)
|
21
dev_github_project_task_connector/models/git_repo.py
Normal file
21
dev_github_project_task_connector/models/git_repo.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class GitRepository(models.Model):
|
||||
_name = "git.repo"
|
||||
_description = "Repository Git"
|
||||
|
||||
name = fields.Char(string="name", required=True)
|
||||
owner = fields.Char(string="Owner", required=True)
|
||||
displayed_name = fields.Char(
|
||||
string="Displayed name", compute="_compute_displayed_name"
|
||||
)
|
||||
|
||||
@api.multi
|
||||
@api.depends("owner", "name")
|
||||
def _compute_displayed_name(self):
|
||||
for record in self:
|
||||
if record.name and record.owner:
|
||||
record.displayed_name = record.owner + "/" + record.name
|
18
dev_github_project_task_connector/models/project_task.py
Normal file
18
dev_github_project_task_connector/models/project_task.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class Task(models.Model):
|
||||
_inherit = "project.task"
|
||||
|
||||
issue_ids = fields.One2many("git.issue", "task_id")
|
||||
|
||||
def link_issue(self):
|
||||
return {
|
||||
"name": "Link a Github issue",
|
||||
"type": "ir.actions.act_window",
|
||||
"view_mode": "form",
|
||||
"res_model": "link.git.issue",
|
||||
"target": "new",
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_git_issue_user,git.issue.user,dev_github_project_task_connector.model_git_issue,project.group_project_user,1,0,0,0
|
||||
access_git_issue_manager,git.issue.manager,dev_github_project_task_connector.model_git_issue,project.group_project_manager,1,1,1,1
|
||||
access_git_repo_user,git.repo.user,dev_github_project_task_connector.model_git_repo,project.group_project_user,1,0,0,0
|
||||
access_git_repo_manager,git.repo.manager,dev_github_project_task_connector.model_git_repo,project.group_project_manager,1,1,1,1
|
|
22
dev_github_project_task_connector/views/git_issue.xml
Normal file
22
dev_github_project_task_connector/views/git_issue.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="view_git_issues_tree" model="ir.ui.view">
|
||||
<field name="name">git_issues.tree</field>
|
||||
<field name="model">git.issue</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<field name="name" />
|
||||
<field name="task_id" />
|
||||
<field name="repo" />
|
||||
<field name="url" />
|
||||
<field name="status" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="act_git_issues_list" model="ir.actions.act_window">
|
||||
<field name="name">Git Issues lines</field>
|
||||
<field name="res_model">git.issue</field>
|
||||
<field name="view_mode">tree</field>
|
||||
</record>
|
||||
</odoo>
|
20
dev_github_project_task_connector/views/git_repository.xml
Normal file
20
dev_github_project_task_connector/views/git_repository.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="view_git_repo_tree" model="ir.ui.view">
|
||||
<field name="name">git.repo.tree</field>
|
||||
<field name="model">git.repo</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree editable="bottom">
|
||||
<field name="owner" />
|
||||
<field name="name" />
|
||||
<field name="displayed_name" readonly="1" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="act_git_repositories_list" model="ir.actions.act_window">
|
||||
<field name="name">Git Repositories lines</field>
|
||||
<field name="res_model">git.repo</field>
|
||||
<field name="view_mode">tree</field>
|
||||
</record>
|
||||
</odoo>
|
9
dev_github_project_task_connector/views/menus.xml
Normal file
9
dev_github_project_task_connector/views/menus.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<menuitem id="menu_git_issues" parent="project.menu_project_config" sequence="20" name="Git issues" />
|
||||
|
||||
<menuitem id="menu_git_repositories" action="act_git_repositories_list" parent="menu_git_issues" sequence="1" name="Git Repositories" />
|
||||
|
||||
<menuitem id="menu_git_issues_list" action="act_git_issues_list" parent="menu_git_issues" sequence="2" name="Git issues list" />
|
||||
|
||||
</odoo>
|
24
dev_github_project_task_connector/views/project_task.xml
Normal file
24
dev_github_project_task_connector/views/project_task.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="view_task_form2_git" model="ir.ui.view">
|
||||
<field name="name">project.task.form.git</field>
|
||||
<field name="model">project.task</field>
|
||||
<field name="inherit_id" ref="project.view_task_form2" />
|
||||
<field name="priority" eval="99" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//notebook" position="inside">
|
||||
<page name="git_issues" string="Git Issues">
|
||||
<button string="Link an issue" name="link_issue" type="object" class="oe_stat_button" icon="fa-link" />
|
||||
<separator string="Current linked issues" />
|
||||
<field name="issue_ids" nolabel="1" mode="tree">
|
||||
<tree create="0" delete="1">
|
||||
<field name="name" />
|
||||
<field name="status" />
|
||||
<field name="url" widget="url" />
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
18
dev_github_project_task_connector/views/res_user.xml
Normal file
18
dev_github_project_task_connector/views/res_user.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="view_users_form_simple_rocketchat_modif" model="ir.ui.view">
|
||||
<field name="name">res.users.rocketchat.preferences.form</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form_simple_modif" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[@name='preferences']" position="after">
|
||||
<group string="Github credentials">
|
||||
<field name="github_login" />
|
||||
<field name="github_password" password="True" />
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
3
dev_github_project_task_connector/wizard/__init__.py
Normal file
3
dev_github_project_task_connector/wizard/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import link_issue
|
27
dev_github_project_task_connector/wizard/link_issue.py
Normal file
27
dev_github_project_task_connector/wizard/link_issue.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, fields
|
||||
from github import Github
|
||||
|
||||
|
||||
class LinkGitIssue(models.TransientModel):
|
||||
_name = "link.git.issue"
|
||||
_description = "Link a Git Issue to a project task"
|
||||
|
||||
issue_repo = fields.Many2one("git.repo", string="Repository", required=True)
|
||||
issue_number = fields.Integer("Issue number", required=True)
|
||||
|
||||
def link_issue(self):
|
||||
github = Github()
|
||||
repo = github.get_repo(self.issue_repo.displayed_name)
|
||||
issue = repo.get_issue(number=self.issue_number)
|
||||
values = {
|
||||
"name": issue.title,
|
||||
"repo": self.issue_repo.id,
|
||||
"status": issue.state,
|
||||
"url": issue.html_url,
|
||||
"task_id": self.env["project.task"]
|
||||
.browse(self._context.get("active_ids"))
|
||||
.id,
|
||||
}
|
||||
self.env["git.issue"].create(values)
|
28
dev_github_project_task_connector/wizard/link_issue.xml
Normal file
28
dev_github_project_task_connector/wizard/link_issue.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="link_issue_wizard" model="ir.ui.view">
|
||||
<field name="name">link_issue.wizard</field>
|
||||
<field name="model">link.git.issue</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Link an existing Github issue to the current task">
|
||||
<group>
|
||||
<field name="issue_repo" widget="selection" placeholder="Choose the repository of the issue" />
|
||||
<field name="issue_number" />
|
||||
</group>
|
||||
<footer>
|
||||
<button string="Link" name="link_issue" type="object" class="btn-primary" />
|
||||
<button string="Cancel" class="btn-secondary" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- <record id="action_link_issue" model="ir.actions.act_window">
|
||||
<field name="name">Link Issue</field>
|
||||
<field name="res_model">link.git.issue</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="link_issue_wizard" />
|
||||
<field name="target">new</field>
|
||||
</record> -->
|
||||
</odoo>
|
Reference in New Issue
Block a user