[FIX] mail: no write on read-only SuggestedRecipientInfo/isSelected
Before this commit, when a recipient is suggested in composer header and current user click on checkbox, there was the following warning in the console: ``` read-only SuggestedRecipientInfo/isSelected on record(SuggestedRecipientInfo_1) was updated ``` The state of a selected suggested recipient is determined by being manually selected on UI, but also that there's a partner related to this recipient. `isSelected` is a computed field with itself as dependency, and it was also imperatively set. We don't want any computed field to be set imperatively, hence the warning in the console. This commit fixes the issue by introducing another field that is specific to selection on UI by current user. This field does not depend on whether there's a partner. This field is imperatively set, and then `isSelected` is fully declarative as a computed field with no self dependency and no imperative update. Task-3032869 closes odoo/odoo#103573 X-original-commit: 8e2980e1e871a8046f09d3d0affb6400ee030eeb Signed-off-by: Louis Wicket (wil) <wil@odoo.com> Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
+1
-1
@@ -62,7 +62,7 @@ export class ComposerSuggestedRecipient extends Component {
|
||||
return;
|
||||
}
|
||||
const isChecked = this._checkboxRef.el.checked;
|
||||
this.composerSuggestedRecipientView.suggestedRecipientInfo.update({ isSelected: isChecked });
|
||||
this.composerSuggestedRecipientView.suggestedRecipientInfo.update({ isChecked });
|
||||
if (!this.composerSuggestedRecipientView.suggestedRecipientInfo.partner) {
|
||||
// Recipients must always be partners. On selecting a suggested
|
||||
// recipient that does not have a partner, the partner creation form
|
||||
|
||||
@@ -32,6 +32,12 @@ registerModel({
|
||||
id: attr({
|
||||
identifying: true,
|
||||
}),
|
||||
/**
|
||||
* Determines whether this suggested recipient has been checked on UI.
|
||||
* A suggested recipient info is checked when current user manually set
|
||||
* checkbox to "checked" value.
|
||||
*/
|
||||
isChecked: attr(),
|
||||
/**
|
||||
* Determines whether `this` will be added to recipients when posting a
|
||||
* new message on `this.thread`.
|
||||
@@ -41,7 +47,7 @@ registerModel({
|
||||
* Prevents selecting a recipient that does not have a partner.
|
||||
*/
|
||||
compute() {
|
||||
return this.partner ? this.isSelected : false;
|
||||
return this.partner ? this.isChecked : false;
|
||||
},
|
||||
default: true,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user