From 194422e2a9205332dbee60b8aa7a8b03a7707ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Sainl=C3=A9ger?= Date: Fri, 1 Jul 2022 09:52:30 +0200 Subject: [PATCH] [UPD] Modify the authentification process to Github Now use a sole Github access for whole Odoo users, set in the General Configuration --- dev_github_connector/__manifest__.py | 4 +-- dev_github_connector/models/__init__.py | 3 ++- .../models/{res_user.py => company.py} | 6 ++--- .../models/res_config_settings.py | 9 +++++++ .../views/res_config_settings_view.xml | 27 +++++++++++++++++++ dev_github_connector/views/res_user.xml | 17 ------------ dev_github_connector/wizard/create_issue.py | 2 +- 7 files changed, 43 insertions(+), 25 deletions(-) rename dev_github_connector/models/{res_user.py => company.py} (52%) create mode 100644 dev_github_connector/models/res_config_settings.py create mode 100644 dev_github_connector/views/res_config_settings_view.xml delete mode 100644 dev_github_connector/views/res_user.xml diff --git a/dev_github_connector/__manifest__.py b/dev_github_connector/__manifest__.py index bae9831..ba46854 100644 --- a/dev_github_connector/__manifest__.py +++ b/dev_github_connector/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Github Odoo Connector", - "version": "12.0.1.0.0", + "version": "12.0.1.1.0", "author": "Elabore", "maintainer": "False", "website": "False", @@ -65,7 +65,7 @@ This module is maintained by ELABORE. }, # always loaded "data": [ - "views/res_user.xml", + "views/res_config_settings_view.xml", "data/git_platform.xml", ], # only loaded in demonstration mode diff --git a/dev_github_connector/models/__init__.py b/dev_github_connector/models/__init__.py index 8038eae..dc6ef40 100644 --- a/dev_github_connector/models/__init__.py +++ b/dev_github_connector/models/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -from . import res_user +from . import res_config_settings +from . import company from . import git_platform from . import git_issue diff --git a/dev_github_connector/models/res_user.py b/dev_github_connector/models/company.py similarity index 52% rename from dev_github_connector/models/res_user.py rename to dev_github_connector/models/company.py index 3ea2763..1d69bc3 100644 --- a/dev_github_connector/models/res_user.py +++ b/dev_github_connector/models/company.py @@ -1,9 +1,7 @@ -# -*- coding: utf-8 -*- - from odoo import models, fields -class Users(models.Model): - _inherit = "res.users" +class Company(models.Model): + _inherit = "res.company" github_token = fields.Char(string="Github token") diff --git a/dev_github_connector/models/res_config_settings.py b/dev_github_connector/models/res_config_settings.py new file mode 100644 index 0000000..e465201 --- /dev/null +++ b/dev_github_connector/models/res_config_settings.py @@ -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 + ) diff --git a/dev_github_connector/views/res_config_settings_view.xml b/dev_github_connector/views/res_config_settings_view.xml new file mode 100644 index 0000000..0dde311 --- /dev/null +++ b/dev_github_connector/views/res_config_settings_view.xml @@ -0,0 +1,27 @@ + + + + res.config.settings.view.form.inherit.github + res.config.settings + + + + +
+

Github configuration

+
+
+
+
+ Github token +
+ +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dev_github_connector/views/res_user.xml b/dev_github_connector/views/res_user.xml deleted file mode 100644 index 2376d5f..0000000 --- a/dev_github_connector/views/res_user.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - res.users.github.preferences.form - res.users - - - - - - - - - - - \ No newline at end of file diff --git a/dev_github_connector/wizard/create_issue.py b/dev_github_connector/wizard/create_issue.py index 9b29467..70cf4d4 100644 --- a/dev_github_connector/wizard/create_issue.py +++ b/dev_github_connector/wizard/create_issue.py @@ -18,7 +18,7 @@ class CreateGitIssue(models.TransientModel): def _create_git_issue(self): values = super(CreateGitIssue, self)._create_git_issue() 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) issue = repo.create_issue( title=self.issue_name, body=self.issue_description