diff --git a/github_connector/wizards/wizard_load_github_model.py b/github_connector/wizards/wizard_load_github_model.py index 9bc73e65..35267d17 100644 --- a/github_connector/wizards/wizard_load_github_model.py +++ b/github_connector/wizards/wizard_load_github_model.py @@ -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): @@ -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: