You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

55 lines
2.0 KiB

# -*- coding: utf-8 -*-
###############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions (odoo@cybrosys.com)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
#
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
import logging
from odoo import fields, models
_logger = logging.getLogger(__name__)
class AuthOAuthProvider(models.Model):
"""Inherits auth.oauth.provider to add fields"""
_inherit = "auth.oauth.provider"
client_secret = fields.Char(string="Client Secret",help="Client Secret Key")
is_github = fields.Boolean(compute='_compute_is_github')
def _compute_is_github(self):
"""
Compute the value for is_github field based on the auth_endpoint
value.
This method iterates over the records to compute the value for the
`is_github` field.
It checks if each record's authentication endpoint contains 'github'.
If the authentication endpoint contains 'github', it sets the
`is_github` field to True.
Otherwise, it sets the `is_github` field to False.
"""
for rec in self:
if rec.auth_endpoint:
if 'github' in rec.auth_endpoint:
rec.is_github = True
else:
rec.is_github = False
else:
rec.is_github = False