mirror of
https://github.com/bringout/oca-ocb-security.git
synced 2026-04-22 10:12:09 +02:00
19.0 vanilla
This commit is contained in:
parent
20ddc1b4a3
commit
c0efcc53f5
1162 changed files with 125577 additions and 105287 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 862 B |
|
|
@ -1,71 +1 @@
|
|||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 70 70">
|
||||
<defs>
|
||||
<mask id="mask" x="0" y="0" width="70" height="70" maskUnits="userSpaceOnUse">
|
||||
<g id="mask-2" data-name="mask">
|
||||
<g id="b">
|
||||
<path id="a" d="M4,0H65c4,0,5,1,5,5V65c0,4-1,5-5,5H4c-3,0-4-1-4-5V5C0,1,1,0,4,0Z" fill="#fff" fill-rule="evenodd"/>
|
||||
</g>
|
||||
</g>
|
||||
</mask>
|
||||
<linearGradient id="linear-gradient" x1="-998.51" y1="-216.96" x2="-999.51" y2="-217.96" gradientTransform="matrix(70, 0, 0, -70, 69966, -15187.42)" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="#94b6c8"/>
|
||||
<stop offset="1" stop-color="#6a9eba"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g mask="url(#mask)">
|
||||
<g>
|
||||
<path d="M0,0H70V70H0Z" fill-rule="evenodd" fill="url(#linear-gradient)"/>
|
||||
<path d="M4,1H65c2.67,0,4.33.67,5,2V0H0V3C.67,1.67,2,1,4,1Z" fill="#fff" fill-opacity="0.38" fill-rule="evenodd"/>
|
||||
<path d="M45.3,69H4c-2,0-4-.14-4-4V33.43l13-13,21.72.11,2.69-2.68L57.05,23l-.28,29L54.33,54.5l.5,1.33,1.34-1.31.88-.16-.37,3.25Z" fill="#393939" fill-rule="evenodd" opacity="0.32" style="isolation: isolate"/>
|
||||
<path d="M4,69H65c2.67,0,4.33-1,5-3v4H0V66A3.92,3.92,0,0,0,4,69Z" fill-opacity="0.38" fill-rule="evenodd"/>
|
||||
<g>
|
||||
<g opacity="0.4">
|
||||
<g>
|
||||
<g>
|
||||
<ellipse cx="21.42" cy="36.92" rx="2.88" ry="4.39"/>
|
||||
<path d="M10.74,22.56V51.79a.57.57,0,0,0,.46.56l21.13,3.9a.56.56,0,0,0,.67-.56V18.3a.57.57,0,0,0-.68-.56L11.19,22A.58.58,0,0,0,10.74,22.56ZM21.42,44.28c-3.23,0-5.85-3.29-5.85-7.36s2.62-7.35,5.85-7.35,5.85,3.29,5.85,7.35S24.65,44.28,21.42,44.28Z"/>
|
||||
</g>
|
||||
<g>
|
||||
<polygon points="36.56 46.29 35.73 46.29 34.89 46.29 34.89 50.77 35.73 50.77 36.56 50.77 37.39 50.77 37.39 46.29 36.56 46.29"/>
|
||||
<path d="M54,19.65H34.92V25.7H53.48V52.56H34.92v1.78H54a1.21,1.21,0,0,0,1.26-1.25V21A1.31,1.31,0,0,0,54,19.65Z"/>
|
||||
<polygon points="49.91 27.49 48.12 27.49 46.33 27.49 46.33 31.97 48.12 31.97 49.91 31.97 51.7 31.97 51.7 27.49 49.91 27.49"/>
|
||||
<polygon points="49.91 33.76 48.12 33.76 46.33 33.76 46.33 38.24 48.12 38.24 49.91 38.24 51.7 38.24 51.7 33.76 49.91 33.76"/>
|
||||
<polygon points="49.91 40.02 48.12 40.02 46.33 40.02 46.33 44.5 48.12 44.5 49.91 44.5 51.7 44.5 51.7 40.02 49.91 40.02"/>
|
||||
<polygon points="42.76 27.49 40.97 27.49 39.18 27.49 39.18 31.97 40.97 31.97 42.76 31.97 44.54 31.97 44.54 27.49 42.76 27.49"/>
|
||||
<polygon points="42.76 33.76 40.97 33.76 39.18 33.76 39.18 38.24 40.97 38.24 42.76 38.24 44.54 38.24 44.54 33.76 42.76 33.76"/>
|
||||
<polygon points="42.76 40.02 40.97 40.02 39.18 40.02 39.18 44.5 40.97 44.5 42.76 44.5 44.54 44.5 44.54 40.02 42.76 40.02"/>
|
||||
<polygon points="42.76 46.29 40.97 46.29 39.18 46.29 39.18 50.77 40.97 50.77 42.76 50.77 44.54 50.77 44.54 46.29 42.76 46.29"/>
|
||||
<polygon points="36.56 27.49 35.73 27.49 34.89 27.49 34.89 31.97 35.73 31.97 36.56 31.97 37.39 31.97 37.39 27.49 36.56 27.49"/>
|
||||
<polygon points="36.56 33.76 35.73 33.76 34.89 33.76 34.89 38.24 35.73 38.24 36.56 38.24 37.39 38.24 37.39 33.76 36.56 33.76"/>
|
||||
<polygon points="36.56 40.02 35.73 40.02 34.89 40.02 34.89 44.5 35.73 44.5 36.56 44.5 37.39 44.5 37.39 40.02 36.56 40.02"/>
|
||||
</g>
|
||||
<polygon points="49.37 56.99 48.33 56.99 48.33 56.35 51.17 56.35 51.17 56.99 50.13 56.99 50.13 59.83 49.37 59.83 49.37 56.99 49.37 56.99"/>
|
||||
<polygon points="51.33 56.35 52.4 56.35 53.21 58.74 53.22 58.74 53.99 56.35 55.06 56.35 55.06 59.83 54.34 59.83 54.34 57.37 54.34 57.37 53.49 59.83 52.9 59.83 52.05 57.39 52.04 57.39 52.04 59.83 51.33 59.83 51.33 56.35"/>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
<g>
|
||||
<ellipse cx="23.41" cy="34.93" rx="2.88" ry="4.39" fill="#fff"/>
|
||||
<path d="M12.73,20.57V49.79a.57.57,0,0,0,.47.56l21.13,3.91a.57.57,0,0,0,.67-.57V16.31a.57.57,0,0,0-.68-.57L13.19,20A.57.57,0,0,0,12.73,20.57ZM23.41,42.28c-3.23,0-5.85-3.29-5.85-7.35s2.62-7.36,5.85-7.36,5.86,3.29,5.86,7.36S26.65,42.28,23.41,42.28Z" fill="#fff"/>
|
||||
</g>
|
||||
<g>
|
||||
<polygon points="38.56 44.29 37.72 44.29 36.89 44.29 36.89 48.77 37.72 48.77 38.56 48.77 39.39 48.77 39.39 44.29 38.56 44.29" fill="#fff"/>
|
||||
<path d="M56,17.65H36.92V23.7H55.48V50.56H36.92v1.79H56a1.22,1.22,0,0,0,1.26-1.25V19A1.32,1.32,0,0,0,56,17.65Z" fill="#fff"/>
|
||||
<polygon points="51.9 25.49 50.12 25.49 48.33 25.49 48.33 29.97 50.12 29.97 51.9 29.97 53.69 29.97 53.69 25.49 51.9 25.49" fill="#fff"/>
|
||||
<polygon points="51.9 31.76 50.12 31.76 48.33 31.76 48.33 36.24 50.12 36.24 51.9 36.24 53.69 36.24 53.69 31.76 51.9 31.76" fill="#fff"/>
|
||||
<polygon points="51.9 38.02 50.12 38.02 48.33 38.02 48.33 42.5 50.12 42.5 51.9 42.5 53.69 42.5 53.69 38.02 51.9 38.02" fill="#fff"/>
|
||||
<polygon points="44.75 25.49 42.97 25.49 41.18 25.49 41.18 29.97 42.97 29.97 44.75 29.97 46.54 29.97 46.54 25.49 44.75 25.49" fill="#fff"/>
|
||||
<polygon points="44.75 31.76 42.97 31.76 41.18 31.76 41.18 36.24 42.97 36.24 44.75 36.24 46.54 36.24 46.54 31.76 44.75 31.76" fill="#fff"/>
|
||||
<polygon points="44.75 38.02 42.97 38.02 41.18 38.02 41.18 42.5 42.97 42.5 44.75 42.5 46.54 42.5 46.54 38.02 44.75 38.02" fill="#fff"/>
|
||||
<polygon points="44.75 44.29 42.97 44.29 41.18 44.29 41.18 48.77 42.97 48.77 44.75 48.77 46.54 48.77 46.54 44.29 44.75 44.29" fill="#fff"/>
|
||||
<polygon points="38.56 25.49 37.72 25.49 36.89 25.49 36.89 29.97 37.72 29.97 38.56 29.97 39.39 29.97 39.39 25.49 38.56 25.49" fill="#fff"/>
|
||||
<polygon points="38.56 31.76 37.72 31.76 36.89 31.76 36.89 36.24 37.72 36.24 38.56 36.24 39.39 36.24 39.39 31.76 38.56 31.76" fill="#fff"/>
|
||||
<polygon points="38.56 38.02 37.72 38.02 36.89 38.02 36.89 42.5 37.72 42.5 38.56 42.5 39.39 42.5 39.39 38.02 38.56 38.02" fill="#fff"/>
|
||||
</g>
|
||||
<polygon points="51.37 55 50.33 55 50.33 54.36 53.16 54.36 53.16 55 52.13 55 52.13 57.83 51.37 57.83 51.37 55 51.37 55" fill="#fff"/>
|
||||
<polygon points="53.33 54.36 54.4 54.36 55.21 56.74 55.22 56.74 55.98 54.36 57.05 54.36 57.05 57.83 56.34 57.83 56.34 55.37 56.33 55.37 55.48 57.83 54.9 57.83 54.05 55.39 54.04 55.39 54.04 57.83 53.33 57.83 53.33 54.36" fill="#fff"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
<svg width="50" height="50" viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg"><path d="M29.2 13.45h15.26c.85 0 1.54.69 1.54 1.54v20.02c0 .85-.69 1.54-1.54 1.54H29.2v-23.1Z" fill="#1976D2"/><path d="M43.9 18.656H29.2v16.319h14.7v-16.32Z" fill="#fff"/><path d="M28.15 46 4 41.275V8.725L28.15 4v42Z" fill="#1976D2"/><path d="M15.813 17.125c-3.335 0-6.038 3.526-6.038 7.875s2.703 7.875 6.037 7.875c3.335 0 6.038-3.526 6.038-7.875 0-4.35-2.703-7.875-6.038-7.875Zm-.263 12.6c-1.74 0-3.15-2.116-3.15-4.725 0-2.61 1.41-4.725 3.15-4.725S18.7 22.39 18.7 25c0 2.609-1.41 4.725-3.15 4.725Z" fill="#fff"/><path d="M32.084 31.023H29.25v3.045h2.835v-3.045Zm3.571 0H32.82v3.045h2.835v-3.045Zm3.572 0h-2.835v3.045h2.834v-3.045Zm-7.143-3.756H29.25v3.045h2.835v-3.045Zm3.571 0H32.82v3.045h2.835v-3.045Zm3.572 0h-2.835v3.045h2.834v-3.045Zm3.57 0h-2.834v3.045h2.834v-3.045Zm-10.713-3.626H29.25v3.045h2.835v-3.045Zm3.571 0H32.82v3.045h2.835v-3.045Zm3.572 0h-2.835v3.045h2.834v-3.045Zm3.57 0h-2.834v3.045h2.834v-3.045Zm-7.142-3.774H32.82v3.045h2.835v-3.045Zm3.572 0h-2.835v3.045h2.834v-3.045Zm3.57 0h-2.834v3.045h2.834v-3.045Z" fill="#1976D2"/></svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.2 KiB |
|
|
@ -1,25 +1,10 @@
|
|||
.o_calendar_sidebar {
|
||||
.bg-primary {
|
||||
background-color: $o-enterprise-primary-color;
|
||||
}
|
||||
.o_microsoft_sync_button {
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.o_microsoft_sync_button_configured {
|
||||
color: white;
|
||||
height: 2em;
|
||||
.o_calendar_sidebar .o_microsoft_sync_button_configured {
|
||||
|
||||
&:hover {
|
||||
#microsoft_check {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
&:not(:hover) {
|
||||
#microsoft_stop {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
&:hover #microsoft_check {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&:not(:hover) #microsoft_stop {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { AttendeeCalendarCommonPopover } from "@calendar/views/attendee_calendar/common/attendee_calendar_common_popover";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(AttendeeCalendarCommonPopover.prototype, "microsoft_calendar_microsoft_calendar_common_popover", {
|
||||
patch(AttendeeCalendarCommonPopover.prototype, {
|
||||
get isEventArchivable() {
|
||||
return this._super() || (this.isCurrentUserOrganizer && this.props.record.rawRecord.microsoft_id);
|
||||
return super.isEventArchivable || (this.isCurrentUserOrganizer && this.props.record.rawRecord.microsoft_id);
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
import { AttendeeCalendarController } from "@calendar/views/attendee_calendar/attendee_calendar_controller";
|
||||
import { user } from "@web/core/user";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { ConfirmationDialog, AlertDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
|
||||
|
||||
patch(AttendeeCalendarController.prototype, "microsoft_calendar_microsoft_calendar_controller", {
|
||||
patch(AttendeeCalendarController.prototype, {
|
||||
setup() {
|
||||
this._super(...arguments);
|
||||
super.setup(...arguments);
|
||||
this.dialog = useService("dialog");
|
||||
this.notification = useService("notification");
|
||||
},
|
||||
|
|
@ -16,7 +16,7 @@ patch(AttendeeCalendarController.prototype, "microsoft_calendar_microsoft_calend
|
|||
await this.orm.call(
|
||||
"res.users",
|
||||
"restart_microsoft_synchronization",
|
||||
[[this.user.userId]],
|
||||
[[user.userId]],
|
||||
);
|
||||
const syncResult = await this.model.syncMicrosoftCalendar();
|
||||
if (syncResult.status === "need_auth") {
|
||||
|
|
@ -24,39 +24,42 @@ patch(AttendeeCalendarController.prototype, "microsoft_calendar_microsoft_calend
|
|||
} else if (syncResult.status === "need_config_from_admin") {
|
||||
if (this.isSystemUser) {
|
||||
this.dialog.add(ConfirmationDialog, {
|
||||
title: this.env._t("Configuration"),
|
||||
body: this.env._t("The Outlook Synchronization needs to be configured before you can use it, do you want to do it now?"),
|
||||
title: _t("Configuration"),
|
||||
body: _t("The Outlook Synchronization needs to be configured before you can use it, do you want to do it now?"),
|
||||
confirm: this.actionService.doAction.bind(this.actionService, syncResult.action),
|
||||
confirmLabel: _t("Configure"),
|
||||
cancel: () => {},
|
||||
cancelLabel: _t("Discard"),
|
||||
});
|
||||
} else {
|
||||
this.dialog.add(AlertDialog, {
|
||||
title: this.env._t("Configuration"),
|
||||
body: this.env._t("An administrator needs to configure Outlook Synchronization before you can use it!"),
|
||||
title: _t("Configuration"),
|
||||
body: _t("An administrator needs to configure Outlook Synchronization before you can use it!"),
|
||||
});
|
||||
}
|
||||
} else if (syncResult.status === "need_refresh") {
|
||||
} else {
|
||||
await this.model.load();
|
||||
this.render(true);
|
||||
}
|
||||
},
|
||||
|
||||
async onStopMicrosoftSynchronization() {
|
||||
this.dialog.add(ConfirmationDialog, {
|
||||
body: this.env._t("You are about to stop the synchronization of your calendar with Outlook. Are you sure you want to continue?"),
|
||||
confirm: async () => {
|
||||
await this.orm.call(
|
||||
"res.users",
|
||||
"stop_microsoft_synchronization",
|
||||
[[this.user.userId]],
|
||||
);
|
||||
this.notification.add(
|
||||
this.env._t("The synchronization with Outlook calendar was successfully stopped."),
|
||||
{
|
||||
title: this.env._t("Success"),
|
||||
type: "success",
|
||||
},
|
||||
);
|
||||
await this.model.load();
|
||||
},
|
||||
});
|
||||
await this.orm.call(
|
||||
"res.users",
|
||||
"stop_microsoft_synchronization",
|
||||
[[user.userId]],
|
||||
);
|
||||
await this.model.load();
|
||||
this.render(true);
|
||||
},
|
||||
|
||||
async onUnpauseMicrosoftSynchronization() {
|
||||
await this.orm.call(
|
||||
"res.users",
|
||||
"unpause_microsoft_synchronization",
|
||||
[[user.userId]],
|
||||
);
|
||||
await this.onStopMicrosoftSynchronization();
|
||||
this.render(true);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,23 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates>
|
||||
<t t-name="microsoft_calendar.MicrosoftCalendarController" t-inherit="calendar.AttendeeCalendarController" t-inherit-mode="extension" owl="1">
|
||||
<xpath expr="//div[@id='calendar_sync_wrapper']" position="attributes">
|
||||
<attribute name="t-if">true</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[@id='microsoft_calendar_sync']" position="replace">
|
||||
<div id="microsoft_calendar_sync" class="o_calendar_sync">
|
||||
<button t-if="!model.microsoftIsSync" type="button" id="microsoft_sync_pending" class="o_microsoft_sync_button o_microsoft_sync_pending btn btn-secondary btn" t-on-click="onMicrosoftSyncCalendar">
|
||||
<b><i class='fa fa-refresh'/> Outlook</b>
|
||||
</button>
|
||||
<!-- class change on hover -->
|
||||
<button t-else="" type="button" id="microsoft_sync_configured" class="me-1 o_microsoft_sync_button o_microsoft_sync_button_configured btn text-bg-primary" t-on-click="onStopMicrosoftSynchronization"
|
||||
t-on-mouseenter="(ev) => {ev.target.classList.remove('text-bg-primary');ev.target.classList.add('text-bg-danger');}"
|
||||
t-on-mouseleave="(ev) => {ev.target.classList.remove('text-bg-danger');ev.target.classList.add('text-bg-primary');}">
|
||||
<b>
|
||||
<i id="microsoft_check" class='fa fa-check'/>
|
||||
<i id="microsoft_stop" class='fa fa-times'/>
|
||||
<span class="mx-1">Outlook</span>
|
||||
</b>
|
||||
<t t-name="microsoft_calendar.MicrosoftCalendarController" t-inherit="calendar.AttendeeCalendarController" t-inherit-mode="extension">
|
||||
<xpath expr="//div[@id='header_synchronization_settings']//h5[@id='synchronize_with']" position="after">
|
||||
<div id="microsoft_calendar_sync" class="mx-1 d-inline-flex" t-if="model.microsoftCredentialsSet and !model.microsoftIsSync and !model.microsoftIsPaused">
|
||||
<button type="button" id="microsoft_sync_pending" class="btn btn-primary text-nowrap" t-on-click="onMicrosoftSyncCalendar">
|
||||
<b>Outlook</b>
|
||||
</button>
|
||||
</div>
|
||||
</xpath>
|
||||
|
|
|
|||
|
|
@ -1,28 +1,29 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { AttendeeCalendarModel } from "@calendar/views/attendee_calendar/attendee_calendar_model";
|
||||
import { rpc } from "@web/core/network/rpc";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { useState } from "@odoo/owl";
|
||||
|
||||
patch(AttendeeCalendarModel, "microsoft_calendar_microsoft_calendar_model", {
|
||||
services: [...AttendeeCalendarModel.services, "rpc"],
|
||||
patch(AttendeeCalendarModel, {
|
||||
services: [...AttendeeCalendarModel.services],
|
||||
});
|
||||
|
||||
patch(AttendeeCalendarModel.prototype, "microsoft_calendar_microsoft_calendar_model_functions", {
|
||||
setup(params, { rpc }) {
|
||||
this._super(...arguments);
|
||||
this.rpc = rpc;
|
||||
patch(AttendeeCalendarModel.prototype, {
|
||||
setup(params) {
|
||||
super.setup(...arguments);
|
||||
this.isAlive = params.isAlive;
|
||||
this.microsoftIsSync = true;
|
||||
this.microsoftPendingSync = false;
|
||||
this.state = useState({
|
||||
microsoftIsSync: true,
|
||||
microsoftIsPaused: false,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
async updateData() {
|
||||
const _super = this._super.bind(this);
|
||||
if (this.microsoftPendingSync) {
|
||||
return _super(...arguments);
|
||||
return super.updateData(...arguments);
|
||||
}
|
||||
try {
|
||||
await Promise.race([
|
||||
|
|
@ -37,13 +38,14 @@ patch(AttendeeCalendarModel.prototype, "microsoft_calendar_microsoft_calendar_mo
|
|||
this.microsoftPendingSync = false;
|
||||
}
|
||||
if (this.isAlive()) {
|
||||
return _super(...arguments);
|
||||
return super.updateData(...arguments);
|
||||
}
|
||||
return new Promise(() => {});
|
||||
},
|
||||
|
||||
async syncMicrosoftCalendar(silent = false) {
|
||||
this.microsoftPendingSync = true;
|
||||
const result = await this.rpc(
|
||||
const result = await rpc(
|
||||
"/microsoft_calendar/sync_data",
|
||||
{
|
||||
model: this.resModel,
|
||||
|
|
@ -53,12 +55,17 @@ patch(AttendeeCalendarModel.prototype, "microsoft_calendar_microsoft_calendar_mo
|
|||
silent,
|
||||
},
|
||||
);
|
||||
if (["need_config_from_admin", "need_auth", "sync_stopped"].includes(result.status)) {
|
||||
this.microsoftIsSync = false;
|
||||
if (["need_config_from_admin", "need_auth", "sync_stopped", "sync_paused"].includes(result.status)) {
|
||||
this.state.microsoftIsSync = false;
|
||||
} else if (result.status === "no_new_event_from_microsoft" || result.status === "need_refresh") {
|
||||
this.microsoftIsSync = true;
|
||||
this.state.microsoftIsSync = true;
|
||||
}
|
||||
this.state.microsoftIsPaused = result.status == "sync_paused";
|
||||
this.microsoftPendingSync = false;
|
||||
return result;
|
||||
},
|
||||
|
||||
get microsoftCredentialsSet() {
|
||||
return this.credentialStatus['microsoft_calendar'] ?? false;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,125 @@
|
|||
import { defineMailModels } from "@mail/../tests/mail_test_helpers";
|
||||
import { beforeEach, expect, test } from "@odoo/hoot";
|
||||
import { animationFrame, mockDate } from "@odoo/hoot-mock";
|
||||
import { defineActions, defineModels, fields, getService, models, mountWebClient, onRpc, serverState, switchView } from "@web/../tests/web_test_helpers";
|
||||
|
||||
class CalendarEvent extends models.Model {
|
||||
_name = "calendar.event";
|
||||
_records = [
|
||||
{
|
||||
id: 5,
|
||||
user_id: serverState.userId,
|
||||
partner_id: 4,
|
||||
name: "event 1",
|
||||
start: "2016-12-13 15:55:05",
|
||||
stop: "2016-12-15 18:55:05",
|
||||
allday: false,
|
||||
partner_ids: [4],
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
user_id: serverState.userId,
|
||||
partner_id: 5,
|
||||
name: "event 2",
|
||||
start: "2016-12-18 08:00:00",
|
||||
stop: "2016-12-18 09:00:00",
|
||||
allday: false,
|
||||
partner_ids: [4],
|
||||
},
|
||||
];
|
||||
_views = {
|
||||
calendar: `
|
||||
<calendar js_class="attendee_calendar" date_start="start" date_stop="stop">
|
||||
<field name="name"/>
|
||||
<field name="partner_ids" write_model="calendar.filter" write_field="partner_id"/>
|
||||
</calendar>
|
||||
`,
|
||||
list: `<list sample="1"/>`
|
||||
};
|
||||
|
||||
user_id = fields.Many2one({ relation: "users" });
|
||||
partner_id = fields.Many2one({ relation: "partner" });
|
||||
name = fields.Char();
|
||||
start = fields.Datetime();
|
||||
stop = fields.Datetime();
|
||||
allday = fields.Boolean();
|
||||
partner_ids = fields.One2many({ relation: "partner" });
|
||||
}
|
||||
|
||||
class CalendarFilter extends models.Model {
|
||||
_records = [
|
||||
{ id: 3, user_id: serverState.userId, partner_id: 4, partner_checked: true },
|
||||
];
|
||||
|
||||
user_id = fields.Many2one({ relation: "users" });
|
||||
partner_id = fields.Many2one({ relation: "partner" });
|
||||
partner_checked = fields.Boolean();
|
||||
}
|
||||
|
||||
class Partner extends models.Model {
|
||||
_records = [
|
||||
{ id: 4, name: "Partner 4", image_1920: "DDD" },
|
||||
{ id: 5, name: "Partner 5", image_1920: "DDD" },
|
||||
];
|
||||
|
||||
name = fields.Char();
|
||||
image_1920 = fields.Binary();
|
||||
}
|
||||
|
||||
class Users extends models.Model {
|
||||
_records = [
|
||||
{ id: serverState.userId, name: "User 4", partner_id: 4 },
|
||||
];
|
||||
|
||||
name = fields.Char();
|
||||
partner_id = fields.Many2one({ relation: "partner" });
|
||||
image_1920 = fields.Binary();
|
||||
}
|
||||
|
||||
defineModels([CalendarEvent, CalendarFilter, Partner, Users]);
|
||||
defineMailModels();
|
||||
|
||||
onRpc("/calendar/check_credentials", async () => ({ microsoft_calendar: true }));
|
||||
onRpc("/microsoft_calendar/sync_data", () => ({ status: "no_new_event_from_microsoft" }));
|
||||
onRpc("check_synchronization_status", async () => ({ microsoft_calendar: "sync_active" }));
|
||||
onRpc("get_attendee_detail", () => []);
|
||||
onRpc("get_default_duration", () => 3.25);
|
||||
|
||||
beforeEach(() => {
|
||||
mockDate("2016-12-12 08:00:00");
|
||||
});
|
||||
|
||||
test(`component is destroyed while sync microsoft calendar`, async () => {
|
||||
defineActions([
|
||||
{
|
||||
id: 1,
|
||||
name: "Partners",
|
||||
res_model: "calendar.event",
|
||||
type: "ir.actions.act_window",
|
||||
views: [[false, "list"], [false, "calendar"]],
|
||||
},
|
||||
]);
|
||||
|
||||
const deferred = Promise.withResolvers();
|
||||
onRpc("/microsoft_calendar/sync_data", async function () {
|
||||
expect.step("sync_data");
|
||||
return deferred.promise;
|
||||
});
|
||||
onRpc("calendar.event", "search_read", ({ method }) => {
|
||||
expect.step(method);
|
||||
});
|
||||
|
||||
await mountWebClient();
|
||||
await getService("action").doAction(1);
|
||||
expect.verifySteps([]);
|
||||
|
||||
await switchView("calendar");
|
||||
expect.verifySteps(["sync_data"]);
|
||||
|
||||
await switchView("calendar");
|
||||
expect.verifySteps(["sync_data"]);
|
||||
|
||||
deferred.resolve();
|
||||
await animationFrame();
|
||||
expect.verifySteps(["search_read"]);
|
||||
});
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { MockServer } from "@web/../tests/helpers/mock_server";
|
||||
|
||||
patch(MockServer.prototype, "microsoft_calendar_mock_server", {
|
||||
/**
|
||||
* Simulate the creation of a custom appointment type
|
||||
* by receiving a list of slots.
|
||||
* @override
|
||||
*/
|
||||
async _performRPC(route, args) {
|
||||
if (route === '/microsoft_calendar/sync_data') {
|
||||
return Promise.resolve({status: 'no_new_event_from_microsoft'});
|
||||
}
|
||||
return this._super(...arguments);
|
||||
},
|
||||
});
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { click, getFixture, patchDate, makeDeferred, nextTick} from "@web/../tests/helpers/utils";
|
||||
import { setupViewRegistries } from "@web/../tests/views/helpers";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { userService } from "@web/core/user_service";
|
||||
import { createWebClient, doAction } from "@web/../tests/webclient/helpers";
|
||||
|
||||
const serviceRegistry = registry.category("services");
|
||||
|
||||
let target;
|
||||
let serverData;
|
||||
const uid = -1;
|
||||
|
||||
QUnit.module('Microsoft Calendar', {
|
||||
beforeEach: function () {
|
||||
patchDate(2016, 11, 12, 8, 0, 0);
|
||||
serverData = {
|
||||
models: {
|
||||
'calendar.event': {
|
||||
fields: {
|
||||
id: {string: "ID", type: "integer"},
|
||||
user_id: {string: "user", type: "many2one", relation: 'user'},
|
||||
partner_id: {string: "user", type: "many2one", relation: 'partner', related: 'user_id.partner_id'},
|
||||
name: {string: "name", type: "char"},
|
||||
start: {string: "start datetime", type: "datetime"},
|
||||
stop: {string: "stop datetime", type: "datetime"},
|
||||
partner_ids: {string: "attendees", type: "one2many", relation: 'partner'},
|
||||
},
|
||||
},
|
||||
'appointment.type': {
|
||||
fields: {},
|
||||
records: [],
|
||||
},
|
||||
user: {
|
||||
fields: {
|
||||
id: {string: "ID", type: "integer"},
|
||||
display_name: {string: "Displayed name", type: "char"},
|
||||
partner_id: {string: "partner", type: "many2one", relation: 'partner'},
|
||||
image_1920: {string: "image", type: "integer"},
|
||||
},
|
||||
records: [
|
||||
{id: 4, display_name: "user 4", partner_id: 4},
|
||||
]
|
||||
},
|
||||
partner: {
|
||||
fields: {
|
||||
id: {string: "ID", type: "integer"},
|
||||
display_name: {string: "Displayed name", type: "char"},
|
||||
image_1920: {string: "image", type: "integer"},
|
||||
},
|
||||
records: [
|
||||
{id: 4, display_name: "partner 4", image_1920: 'DDD'},
|
||||
{id: 5, display_name: "partner 5", image_1920: 'DDD'},
|
||||
]
|
||||
},
|
||||
filter_partner: {
|
||||
fields: {
|
||||
id: {string: "ID", type: "integer"},
|
||||
user_id: {string: "user", type: "many2one", relation: 'user'},
|
||||
partner_id: {string: "partner", type: "many2one", relation: 'partner'},
|
||||
partner_checked: {string: "checked", type: "boolean"},
|
||||
},
|
||||
records: [
|
||||
{id: 3, user_id: uid, partner_id: 4, partner_checked: true}
|
||||
]
|
||||
},
|
||||
},
|
||||
views: {},
|
||||
};
|
||||
target = getFixture();
|
||||
setupViewRegistries();
|
||||
serviceRegistry.add(
|
||||
"user",
|
||||
{
|
||||
...userService,
|
||||
start() {
|
||||
const fakeUserService = userService.start(...arguments);
|
||||
Object.defineProperty(fakeUserService, "userId", {
|
||||
get: () => uid,
|
||||
});
|
||||
return fakeUserService;
|
||||
},
|
||||
},
|
||||
{ force: true }
|
||||
);
|
||||
}
|
||||
}, function () {
|
||||
|
||||
QUnit.test("component is destroyed while sync microsoft calendar", async function (assert) {
|
||||
assert.expect(4);
|
||||
const def = makeDeferred();
|
||||
serverData.actions = {
|
||||
1: {
|
||||
id: 1,
|
||||
name: "Partners",
|
||||
res_model: "calendar.event",
|
||||
type: "ir.actions.act_window",
|
||||
views: [
|
||||
[false, "list"],
|
||||
[false, "calendar"],
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
serverData.views = {
|
||||
"calendar.event,false,calendar": `
|
||||
<calendar class="o_calendar_test" js_class="attendee_calendar" date_start="start" date_stop="stop">
|
||||
<field name="name"/>
|
||||
<field name="partner_ids" write_model="filter_partner" write_field="partner_id"/>
|
||||
</calendar>`,
|
||||
"calendar.event,false,list": `<tree sample="1" />`,
|
||||
"calendar.event,false,search": `<search />`,
|
||||
};
|
||||
|
||||
const webClient = await createWebClient({
|
||||
serverData,
|
||||
async mockRPC(route, args) {
|
||||
if (route === '/microsoft_calendar/sync_data') {
|
||||
assert.step(route);
|
||||
return def;
|
||||
} else if (route === '/web/dataset/call_kw/calendar.event/search_read') {
|
||||
assert.step(route);
|
||||
} else if (route === '/web/dataset/call_kw/res.partner/get_attendee_detail') {
|
||||
return Promise.resolve([]);
|
||||
} else if (route === '/web/dataset/call_kw/res.users/has_group') {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
await doAction(webClient, 1);
|
||||
|
||||
click(target.querySelector(".o_cp_switch_buttons .o_calendar"));
|
||||
await nextTick();
|
||||
|
||||
click(target.querySelector(".o_cp_switch_buttons .o_calendar"));
|
||||
await nextTick();
|
||||
|
||||
def.resolve();
|
||||
await nextTick();
|
||||
|
||||
assert.verifySteps([
|
||||
"/microsoft_calendar/sync_data",
|
||||
"/microsoft_calendar/sync_data",
|
||||
"/web/dataset/call_kw/calendar.event/search_read"
|
||||
], "Correct RPC calls were made");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue