Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion github_connector/wizards/wizard_load_github_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models
from odoo import exceptions, fields, models


class WizardLoadGithubModel(models.TransientModel):
Expand All @@ -28,10 +28,34 @@ class WizardLoadGithubModel(models.TransientModel):
def button_create_from_github(self):
for wizard in self:
if wizard.github_type == "organization":
if "/" in wizard.name:
raise exceptions.UserError(
self.env._(
"You selected 'Organization' but provided a repository "
"name containing a '/'. Please select 'Repository' "
"as the Github Type Name instead."
)
)
github_model = self.env["github.organization"]
elif wizard.github_type == "user":
if "/" in wizard.name:
raise exceptions.UserError(
self.env._(
"You selected 'User' but provided a repository name"
" containing a '/'. Please select 'Repository' "
"as the Github Type Name instead."
)
)
github_model = self.env["res.partner"]
elif wizard.github_type == "repository":
if "/" not in wizard.name:
raise exceptions.UserError(
self.env._(
"You selected 'Repository' but provided a name "
"without a '/'. Repositories should be in the format "
"'organization/repository'."
)
)
github_model = self.env["github.repository"]
my_obj = github_model.create_from_name(wizard.name)
if wizard.child_update:
Expand Down
Loading