[UPD] Modify the authentification process to Github
Now use a sole Github access for whole Odoo users, set in the General Configuration
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "Github Odoo Connector",
|
"name": "Github Odoo Connector",
|
||||||
"version": "12.0.1.0.0",
|
"version": "12.0.1.1.0",
|
||||||
"author": "Elabore",
|
"author": "Elabore",
|
||||||
"maintainer": "False",
|
"maintainer": "False",
|
||||||
"website": "False",
|
"website": "False",
|
||||||
@@ -65,7 +65,7 @@ This module is maintained by ELABORE.
|
|||||||
},
|
},
|
||||||
# always loaded
|
# always loaded
|
||||||
"data": [
|
"data": [
|
||||||
"views/res_user.xml",
|
"views/res_config_settings_view.xml",
|
||||||
"data/git_platform.xml",
|
"data/git_platform.xml",
|
||||||
],
|
],
|
||||||
# only loaded in demonstration mode
|
# only loaded in demonstration mode
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from . import res_user
|
from . import res_config_settings
|
||||||
|
from . import company
|
||||||
from . import git_platform
|
from . import git_platform
|
||||||
from . import git_issue
|
from . import git_issue
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from odoo import models, fields
|
from odoo import models, fields
|
||||||
|
|
||||||
|
|
||||||
class Users(models.Model):
|
class Company(models.Model):
|
||||||
_inherit = "res.users"
|
_inherit = "res.company"
|
||||||
|
|
||||||
github_token = fields.Char(string="Github token")
|
github_token = fields.Char(string="Github token")
|
9
dev_github_connector/models/res_config_settings.py
Normal file
9
dev_github_connector/models/res_config_settings.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ResConfigSettings(models.TransientModel):
|
||||||
|
_inherit = "res.config.settings"
|
||||||
|
|
||||||
|
github_token = fields.Char(
|
||||||
|
related="company_id.github_token", string="Github token", readonly=False
|
||||||
|
)
|
27
dev_github_connector/views/res_config_settings_view.xml
Normal file
27
dev_github_connector/views/res_config_settings_view.xml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="res_config_settings_view_form_github" model="ir.ui.view">
|
||||||
|
<field name="name">res.config.settings.view.form.inherit.github</field>
|
||||||
|
<field name="model">res.config.settings</field>
|
||||||
|
<field name="priority" eval="99" />
|
||||||
|
<field name="inherit_id" ref="base.res_config_settings_view_form" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//div[hasclass('settings')]" position="inside">
|
||||||
|
<div class="app_settings_block" data-string="github" string="Github" data-key="dev_github_connector">
|
||||||
|
<h2>Github configuration</h2>
|
||||||
|
<div class="row mt16 o_settings_container" id="github_settings">
|
||||||
|
<div class="col-12 col-lg-6 o_setting_box" id="github_tokenl">
|
||||||
|
<div class="o_setting_left_pane" />
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<span class="o_form_label">Github token</span>
|
||||||
|
<div class="text-muted">
|
||||||
|
<field name="github_token" widget="password" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
@@ -1,17 +0,0 @@
|
|||||||
<?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>
|
|
@@ -18,7 +18,7 @@ class CreateGitIssue(models.TransientModel):
|
|||||||
def _create_git_issue(self):
|
def _create_git_issue(self):
|
||||||
values = super(CreateGitIssue, self)._create_git_issue()
|
values = super(CreateGitIssue, self)._create_git_issue()
|
||||||
if self.issue_platform.tool == "github":
|
if self.issue_platform.tool == "github":
|
||||||
github = Github(self.env.user.github_token)
|
github = Github(self.env.user.company_id.github_token)
|
||||||
repo = github.get_repo(self.issue_repo.displayed_name)
|
repo = github.get_repo(self.issue_repo.displayed_name)
|
||||||
issue = repo.create_issue(
|
issue = repo.create_issue(
|
||||||
title=self.issue_name, body=self.issue_description
|
title=self.issue_name, body=self.issue_description
|
||||||
|
Reference in New Issue
Block a user