Files
project_v19/auth_oauth_company_website/models/models.py
T
2026-07-01 14:41:49 +07:00

23 lines
876 B
Python

from odoo import models, fields, api
class AuthOAuthProvider(models.Model):
_inherit = 'auth.oauth.provider'
company_id = fields.Many2one(
'res.company',
string='Allowed Company',
help="If set, this provider is only available for this company's users."
)
website_id = fields.Many2one(
'website',
string='Allowed Website',
help="If set, this provider button will only show on this website's login page."
)
@api.onchange('company_id')
def _onchange_company_id(self):
"""Automatically link website if company is selected and only one website exists for that company"""
if self.company_id and not self.website_id:
website = self.env['website'].search([('company_id', '=', self.company_id.id)], limit=1)
if website:
self.website_id = website.id