[NEW] Add Git issue creation functionnality
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
from . import wizard
|
||||
|
@@ -64,7 +64,9 @@ This module is maintained by ELABORE.
|
||||
"python": [],
|
||||
},
|
||||
# always loaded
|
||||
"data": [],
|
||||
"data": [
|
||||
"views/res_user.xml",
|
||||
],
|
||||
# only loaded in demonstration mode
|
||||
"demo": [],
|
||||
"js": [],
|
||||
|
3
dev_github_connector/models/__init__.py
Normal file
3
dev_github_connector/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import res_user
|
9
dev_github_connector/models/res_user.py
Normal file
9
dev_github_connector/models/res_user.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class Users(models.Model):
|
||||
_inherit = "res.users"
|
||||
|
||||
github_token = fields.Char(string="Github token")
|
17
dev_github_connector/views/res_user.xml
Normal file
17
dev_github_connector/views/res_user.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="view_users_form_simple_gitub_token" model="ir.ui.view">
|
||||
<field name="name">res.users.github.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_token" readonly="0" />
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
@@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import link_issue
|
||||
from . import create_issue
|
||||
|
32
dev_github_connector/wizard/create_issue.py
Normal file
32
dev_github_connector/wizard/create_issue.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models
|
||||
from github import Github
|
||||
|
||||
|
||||
class CreateGitIssue(models.TransientModel):
|
||||
_inherit = "create.git.issue"
|
||||
|
||||
def _convert_issue_status(self, status):
|
||||
if status == "open":
|
||||
return "opened"
|
||||
elif status == "closed":
|
||||
return "closed"
|
||||
else:
|
||||
return super(CreateGitIssue, self)._convert_issue_status(status)
|
||||
|
||||
def _create_git_issue(self):
|
||||
values = super(CreateGitIssue, self)._create_git_issue()
|
||||
github = Github(self.env.user.github_token)
|
||||
repo = github.get_repo(self.issue_repo.displayed_name)
|
||||
issue = repo.create_issue(title=self.issue_name, body=self.issue_description)
|
||||
values = {
|
||||
"name": issue.title,
|
||||
"repo": self.issue_repo.id,
|
||||
"status": self._convert_issue_status(issue.state),
|
||||
"url": issue.html_url,
|
||||
"task_id": self.env["project.task"]
|
||||
.browse(self._context.get("active_ids"))
|
||||
.id,
|
||||
}
|
||||
return values
|
Reference in New Issue
Block a user