[FIX] mail: Cannot read property "rtc" of undefined

Also resulted in crash `Cannot read property 'sel' of undefined`.

This commit adds some guards in some component templates
that access model records and their fields, to avoid crashes.

These guards are necessary due to the asynchronous rendering of OWL,
which makes it vulnerable to risky changes in models such as
record deletion or any modifcation in any relational fields.

Introduced with https://github.com/odoo/odoo/commit/9bf4b6c29207b97368f27098df3cfbe79e2b5f0f

closes odoo/odoo#77258

X-original-commit: 1dbf02ea72aa0599991f05ff2d9d4f4517055eca
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
This commit is contained in:
Alexandre Kühn
2021-09-27 16:57:14 +00:00
parent 5e377e9c48
commit 017f738c5d
2 changed files with 16 additions and 14 deletions
@@ -3,19 +3,21 @@
<t t-name="mail.RtcActivityNotice" owl="1">
<li class="o_RtcActivityNotice">
<RtcInvitations/>
<t t-if="messaging.rtc.channel">
<t t-set="title">Open conference: <t t-esc="messaging.rtc.channel.displayName"/></t>
<a class="o_RtcActivityNotice_button" t-att-title="title" role="button" t-on-click="_onClick">
<div class="o_RtcActivityNotice_buttonContent">
<span class="o_RtcActivityNotice_buttonTitle" t-esc="messaging.rtc.channel.displayName"/>
<i class="o_RtcActivityNotice_outputIndicator fa" t-att-class="{
'fa-microphone': !messaging.rtc.sendDisplay and !messaging.rtc.sendUserVideo,
'fa-video-camera': messaging.rtc.sendUserVideo,
'fa-desktop': messaging.rtc.sendDisplay,
}"/>
</div>
</a>
<t t-if="messaging">
<RtcInvitations/>
<t t-if="messaging.rtc.channel">
<t t-set="title">Open conference: <t t-esc="messaging.rtc.channel.displayName"/></t>
<a class="o_RtcActivityNotice_button" t-att-title="title" role="button" t-on-click="_onClick">
<div class="o_RtcActivityNotice_buttonContent">
<span class="o_RtcActivityNotice_buttonTitle" t-esc="messaging.rtc.channel.displayName"/>
<i class="o_RtcActivityNotice_outputIndicator fa" t-att-class="{
'fa-microphone': !messaging.rtc.sendDisplay and !messaging.rtc.sendUserVideo,
'fa-video-camera': messaging.rtc.sendUserVideo,
'fa-desktop': messaging.rtc.sendDisplay,
}"/>
</div>
</a>
</t>
</t>
</li>
</t>
@@ -3,7 +3,7 @@
<t t-name="mail.RtcController" owl="1">
<div class="o_RtcController">
<t t-if="rtcController">
<t t-if="rtcController and messaging">
<div class="o_RtcController_buttons">
<t t-if="rtcController.callViewer.threadView.thread.rtc and messaging.rtc.currentRtcSession">
<t t-if="messaging.rtc.currentRtcSession.isMuted"><t t-set="microphoneTitle">Unmute</t></t>