update
This commit is contained in:
83
fusion_schedule/models/res_config_settings.py
Normal file
83
fusion_schedule/models/res_config_settings.py
Normal file
@@ -0,0 +1,83 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
# Google OAuth — dedicated keys with fallback to Odoo defaults
|
||||
x_fc_google_client_id = fields.Char(
|
||||
string='Google Client ID',
|
||||
config_parameter='fusion_schedule_google_client_id',
|
||||
)
|
||||
x_fc_google_client_secret = fields.Char(
|
||||
string='Google Client Secret',
|
||||
config_parameter='fusion_schedule_google_client_secret',
|
||||
)
|
||||
x_fc_google_has_fallback = fields.Boolean(
|
||||
string='Google Using Odoo Default',
|
||||
compute='_compute_google_has_fallback',
|
||||
)
|
||||
|
||||
# Microsoft OAuth — dedicated keys with fallback to Odoo defaults
|
||||
x_fc_microsoft_client_id = fields.Char(
|
||||
string='Microsoft Client ID',
|
||||
config_parameter='fusion_schedule_microsoft_client_id',
|
||||
)
|
||||
x_fc_microsoft_client_secret = fields.Char(
|
||||
string='Microsoft Client Secret',
|
||||
config_parameter='fusion_schedule_microsoft_client_secret',
|
||||
)
|
||||
x_fc_microsoft_has_fallback = fields.Boolean(
|
||||
string='Microsoft Using Odoo Default',
|
||||
compute='_compute_microsoft_has_fallback',
|
||||
)
|
||||
|
||||
# Sync settings
|
||||
x_fc_sync_interval_minutes = fields.Integer(
|
||||
string='Sync Interval (minutes)',
|
||||
config_parameter='fusion_schedule_sync_interval',
|
||||
default=5,
|
||||
)
|
||||
|
||||
# Schedule defaults
|
||||
x_fc_default_work_start = fields.Float(
|
||||
string='Default Work Start',
|
||||
config_parameter='fusion_schedule.default_work_start',
|
||||
default=9.0,
|
||||
)
|
||||
x_fc_default_work_end = fields.Float(
|
||||
string='Default Work End',
|
||||
config_parameter='fusion_schedule.default_work_end',
|
||||
default=17.0,
|
||||
)
|
||||
x_fc_default_break_start = fields.Float(
|
||||
string='Default Break Start',
|
||||
config_parameter='fusion_schedule.default_break_start',
|
||||
default=12.0,
|
||||
)
|
||||
x_fc_default_break_duration = fields.Float(
|
||||
string='Default Break Duration',
|
||||
config_parameter='fusion_schedule.default_break_duration',
|
||||
default=0.5,
|
||||
)
|
||||
x_fc_default_travel_buffer = fields.Integer(
|
||||
string='Default Travel Buffer (min)',
|
||||
config_parameter='fusion_schedule.default_travel_buffer',
|
||||
default=30,
|
||||
)
|
||||
|
||||
@api.depends('x_fc_google_client_id')
|
||||
def _compute_google_has_fallback(self):
|
||||
ICP = self.env['ir.config_parameter'].sudo()
|
||||
odoo_default = ICP.get_param('google_calendar_client_id', '')
|
||||
for rec in self:
|
||||
rec.x_fc_google_has_fallback = bool(not rec.x_fc_google_client_id and odoo_default)
|
||||
|
||||
@api.depends('x_fc_microsoft_client_id')
|
||||
def _compute_microsoft_has_fallback(self):
|
||||
ICP = self.env['ir.config_parameter'].sudo()
|
||||
odoo_default = ICP.get_param('microsoft_calendar_client_id', '')
|
||||
for rec in self:
|
||||
rec.x_fc_microsoft_has_fallback = bool(not rec.x_fc_microsoft_client_id and odoo_default)
|
||||
Reference in New Issue
Block a user