mirror of
https://github.com/bringout/oca-ocb-technical.git
synced 2026-04-20 09:32:00 +02:00
Initial commit: Technical packages
This commit is contained in:
commit
3473fa71a0
873 changed files with 297766 additions and 0 deletions
|
|
@ -0,0 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
|
||||
from . import calendar_provider_config
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,50 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo.addons.base.models.ir_module import assert_log_admin_access
|
||||
|
||||
|
||||
class CalendarProviderConfig(models.TransientModel):
|
||||
_name = 'calendar.provider.config'
|
||||
_description = 'Calendar Provider Configuration Wizard'
|
||||
|
||||
external_calendar_provider = fields.Selection([
|
||||
('google', 'Google'), ('microsoft', 'Outlook')],
|
||||
"Choose an external calendar to configure", default='google')
|
||||
|
||||
# Allow to sync with eventually existing ICP keys without creating them if respective module is not installed
|
||||
# Using same field names and strings as their respective res.config.settings
|
||||
cal_client_id = fields.Char(
|
||||
"Google Client_id",
|
||||
default=lambda self: self.env['ir.config_parameter'].get_param('google_calendar_client_id'))
|
||||
cal_client_secret = fields.Char(
|
||||
"Google Client_key",
|
||||
default=lambda self: self.env['ir.config_parameter'].get_param('google_calendar_client_secret'))
|
||||
microsoft_outlook_client_identifier = fields.Char(
|
||||
"Outlook Client Id",
|
||||
default=lambda self: self.env['ir.config_parameter'].get_param('microsoft_calendar_client_id'))
|
||||
microsoft_outlook_client_secret = fields.Char(
|
||||
"Outlook Client Secret",
|
||||
default=lambda self: self.env['ir.config_parameter'].get_param('microsoft_calendar_client_secret'))
|
||||
|
||||
@assert_log_admin_access
|
||||
def action_calendar_prepare_external_provider_sync(self):
|
||||
""" Called by the wizard to configure an external calendar provider without requiring users
|
||||
to access the general settings page.
|
||||
Make sure that the provider calendar module is installed or install it. Then, set
|
||||
the API keys into the applicable config parameters.
|
||||
"""
|
||||
self.ensure_one()
|
||||
calendar_module = self.env['ir.module.module'].search([
|
||||
('name', '=', f'{self.external_calendar_provider}_calendar')])
|
||||
|
||||
if calendar_module.state != 'installed':
|
||||
calendar_module.button_immediate_install()
|
||||
|
||||
if self.external_calendar_provider == 'google':
|
||||
self.env['ir.config_parameter'].set_param('google_calendar_client_id', self.cal_client_id)
|
||||
self.env['ir.config_parameter'].set_param('google_calendar_client_secret', self.cal_client_secret)
|
||||
elif self.external_calendar_provider == 'microsoft':
|
||||
self.env['ir.config_parameter'].set_param('microsoft_calendar_client_id', self.microsoft_outlook_client_identifier)
|
||||
self.env['ir.config_parameter'].set_param('microsoft_calendar_client_secret', self.microsoft_outlook_client_secret)
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="calendar_provider_config_view_form" model="ir.ui.view">
|
||||
<field name="name">calendar.provider.config.view.form</field>
|
||||
<field name="model">calendar.provider.config</field>
|
||||
<field name="arch" type="xml">
|
||||
<form js_class="calendar_provider_config_form">
|
||||
<field name="external_calendar_provider" widget="radio" options="{'horizontal': true}"/>
|
||||
<div attrs="{'invisible': [('external_calendar_provider', '!=', 'google')]}">
|
||||
<img alt="Google Calendar icon" src="/calendar/static/src/img/google_calendar_40.png" style="height: 40px; margin-right: 5px"/>
|
||||
<span class="me-1 o_form_label">Google Calendar</span>
|
||||
<a href="https://www.odoo.com/documentation/16.0/applications/productivity/calendar/google.html" title="Read More" class="o_doc_link" target="_blank"></a>
|
||||
<div class="text-muted mt-2">
|
||||
Synchronize your calendar with Google Calendar
|
||||
</div>
|
||||
<group>
|
||||
<field name="cal_client_id" attrs="{'required': [('external_calendar_provider', '=', 'google')]}"/>
|
||||
<field name="cal_client_secret" password="True" attrs="{'required': [('external_calendar_provider', '=', 'google')]}"/>
|
||||
</group>
|
||||
</div>
|
||||
<div attrs="{'invisible': [('external_calendar_provider', '!=', 'microsoft')]}">
|
||||
<img alt="Microsoft Outlook icon" src="/calendar/static/src/img/microsoft_calendar_40.png" style="height: 40px; margin-right: 5px"/>
|
||||
<span class="me-1 o_form_label">Outlook Calendar</span>
|
||||
<a href="https://www.odoo.com/documentation/16.0/applications/productivity/calendar/outlook.html" title="Read More" class="o_doc_link" target="_blank"></a>
|
||||
<div class="text-muted mt-2">
|
||||
Synchronize your calendar with Outlook
|
||||
</div>
|
||||
<group>
|
||||
<field name="microsoft_outlook_client_identifier" attrs="{'required': [('external_calendar_provider', '=', 'microsoft')]}"/>
|
||||
<field name="microsoft_outlook_client_secret" password="True" attrs="{'required': [('external_calendar_provider', '=', 'microsoft')]}"/>
|
||||
</group>
|
||||
</div>
|
||||
<footer>
|
||||
<a role="button" title="Connect" class="o_calendar_activate_external_cal btn btn-primary" t-on-click="onConnect">Connect</a>
|
||||
<button string="Cancel" class="btn btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue