From c0cb6c95c1c991f64b17844f8dd0762c4bebbb80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Sainl=C3=A9ger?= Date: Fri, 10 Jun 2022 01:04:50 +0200 Subject: [PATCH] [NEW] Addons dev_github_project_task_connector creation --- dev_github_project_task_connector/__init__.py | 4 + .../__manifest__.py | 88 +++++++++++++++++++ .../models/__init__.py | 5 ++ .../models/git_issue.py | 23 +++++ .../models/git_repo.py | 21 +++++ .../models/project_task.py | 18 ++++ .../security/ir.model.access.csv | 5 ++ .../views/git_issue.xml | 22 +++++ .../views/git_repository.xml | 20 +++++ .../views/menus.xml | 9 ++ .../views/project_task.xml | 24 +++++ .../views/res_user.xml | 18 ++++ .../wizard/__init__.py | 3 + .../wizard/link_issue.py | 27 ++++++ .../wizard/link_issue.xml | 28 ++++++ 15 files changed, 315 insertions(+) create mode 100644 dev_github_project_task_connector/__init__.py create mode 100644 dev_github_project_task_connector/__manifest__.py create mode 100644 dev_github_project_task_connector/models/__init__.py create mode 100644 dev_github_project_task_connector/models/git_issue.py create mode 100644 dev_github_project_task_connector/models/git_repo.py create mode 100644 dev_github_project_task_connector/models/project_task.py create mode 100644 dev_github_project_task_connector/security/ir.model.access.csv create mode 100644 dev_github_project_task_connector/views/git_issue.xml create mode 100644 dev_github_project_task_connector/views/git_repository.xml create mode 100644 dev_github_project_task_connector/views/menus.xml create mode 100644 dev_github_project_task_connector/views/project_task.xml create mode 100644 dev_github_project_task_connector/views/res_user.xml create mode 100644 dev_github_project_task_connector/wizard/__init__.py create mode 100644 dev_github_project_task_connector/wizard/link_issue.py create mode 100644 dev_github_project_task_connector/wizard/link_issue.xml diff --git a/dev_github_project_task_connector/__init__.py b/dev_github_project_task_connector/__init__.py new file mode 100644 index 0000000..35e7c96 --- /dev/null +++ b/dev_github_project_task_connector/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import models +from . import wizard diff --git a/dev_github_project_task_connector/__manifest__.py b/dev_github_project_task_connector/__manifest__.py new file mode 100644 index 0000000..1ac4f66 --- /dev/null +++ b/dev_github_project_task_connector/__manifest__.py @@ -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 +`_. 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 `_. + +Contributors +------------ +* Stéphan Sainléger + +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, +} diff --git a/dev_github_project_task_connector/models/__init__.py b/dev_github_project_task_connector/models/__init__.py new file mode 100644 index 0000000..ed0d1df --- /dev/null +++ b/dev_github_project_task_connector/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- + +from . import project_task +from . import git_issue +from . import git_repo diff --git a/dev_github_project_task_connector/models/git_issue.py b/dev_github_project_task_connector/models/git_issue.py new file mode 100644 index 0000000..abe92eb --- /dev/null +++ b/dev_github_project_task_connector/models/git_issue.py @@ -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) diff --git a/dev_github_project_task_connector/models/git_repo.py b/dev_github_project_task_connector/models/git_repo.py new file mode 100644 index 0000000..a479a0d --- /dev/null +++ b/dev_github_project_task_connector/models/git_repo.py @@ -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 diff --git a/dev_github_project_task_connector/models/project_task.py b/dev_github_project_task_connector/models/project_task.py new file mode 100644 index 0000000..fd2b8ec --- /dev/null +++ b/dev_github_project_task_connector/models/project_task.py @@ -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", + } diff --git a/dev_github_project_task_connector/security/ir.model.access.csv b/dev_github_project_task_connector/security/ir.model.access.csv new file mode 100644 index 0000000..b3f700b --- /dev/null +++ b/dev_github_project_task_connector/security/ir.model.access.csv @@ -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 \ No newline at end of file diff --git a/dev_github_project_task_connector/views/git_issue.xml b/dev_github_project_task_connector/views/git_issue.xml new file mode 100644 index 0000000..a946b89 --- /dev/null +++ b/dev_github_project_task_connector/views/git_issue.xml @@ -0,0 +1,22 @@ + + + + git_issues.tree + git.issue + + + + + + + + + + + + + Git Issues lines + git.issue + tree + + \ No newline at end of file diff --git a/dev_github_project_task_connector/views/git_repository.xml b/dev_github_project_task_connector/views/git_repository.xml new file mode 100644 index 0000000..d8e0984 --- /dev/null +++ b/dev_github_project_task_connector/views/git_repository.xml @@ -0,0 +1,20 @@ + + + + git.repo.tree + git.repo + + + + + + + + + + + Git Repositories lines + git.repo + tree + + \ No newline at end of file diff --git a/dev_github_project_task_connector/views/menus.xml b/dev_github_project_task_connector/views/menus.xml new file mode 100644 index 0000000..aa41453 --- /dev/null +++ b/dev_github_project_task_connector/views/menus.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/dev_github_project_task_connector/views/project_task.xml b/dev_github_project_task_connector/views/project_task.xml new file mode 100644 index 0000000..5955760 --- /dev/null +++ b/dev_github_project_task_connector/views/project_task.xml @@ -0,0 +1,24 @@ + + + + project.task.form.git + project.task + + + + + +