[FIX] mail: avoid crashing on partner created from lead

Delete obsolete suggested_recipient_info with isCausal and ensure thread is
required on it.

This is intended to prevent crashing when creating a new partner from a
lead.

Task-2654859

closes odoo/odoo#79619

X-original-commit: fdbbed270d0c266a0e495136b461a4c40f8394bf
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Louis Wicket (wil)
2021-11-10 12:54:44 +00:00
committed by Sébastien Theys
parent 114a5885ba
commit bf71f4e7c2
3 changed files with 3 additions and 1 deletions
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="mail.ComposerSuggestedRecipient" owl="1">
<div class="o_ComposerSuggestedRecipient" t-att-data-partner-id="suggestedRecipientInfo.partner and suggestedRecipientInfo.partner.id ? suggestedRecipientInfo.partner.id : false" t-att-title="ADD_AS_RECIPIENT_AND_FOLLOWER_REASON">
<div class="o_ComposerSuggestedRecipient" t-att-data-partner-id="suggestedRecipientInfo and suggestedRecipientInfo.partner and suggestedRecipientInfo.partner.id ? suggestedRecipientInfo.partner.id : false" t-att-title="ADD_AS_RECIPIENT_AND_FOLLOWER_REASON">
<t t-if="suggestedRecipientInfo">
<div class="custom-control custom-checkbox">
<input t-attf-id="{{ id }}_checkbox" class="custom-control-input" type="checkbox" t-att-checked="suggestedRecipientInfo.isSelected ? 'checked' : undefined" t-on-change="_onChangeCheckbox" t-ref="checkbox" />
@@ -78,6 +78,7 @@ function factory(dependencies) {
*/
thread: many2one('mail.thread', {
inverse: 'suggestedRecipientInfoList',
required: true,
}),
};
SuggestedRecipientInfo.identifyingFields = ['id'];
@@ -2440,6 +2440,7 @@ function factory(dependencies) {
*/
suggestedRecipientInfoList: one2many('mail.suggested_recipient_info', {
inverse: 'thread',
isCausal: true,
}),
/**
* Determines the last content of the last composer related to this