[IMP] mail: remove willCreate lifecyle hook
This lifecyle is useless. All attributes that were defined using this hooks should become fields. This commit remove `willCreate`, and turn attributes to fields. Task-2837763 closes odoo/odoo#90198 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
@@ -190,7 +190,7 @@ function assertIsFunction(toAssert) {
|
||||
* @throws {Error} if name is not an existing hook name.
|
||||
*/
|
||||
function assertIsValidHookName(name) {
|
||||
const validHookNames = new Set(['_created', '_willCreate', '_willDelete']);
|
||||
const validHookNames = new Set(['_created', '_willDelete']);
|
||||
if (!validHookNames.has(name)) {
|
||||
throw new Error("invalid hook name.");
|
||||
}
|
||||
|
||||
@@ -709,15 +709,6 @@ export class ModelManager {
|
||||
for (const methodName of recordMethods.keys()) {
|
||||
record[methodName] = record[methodName].bind(record);
|
||||
}
|
||||
/**
|
||||
* Invoke the life-cycle hook `_willCreate.`
|
||||
* After this step the record is in a functioning state and it is
|
||||
* considered existing.
|
||||
*/
|
||||
const lifecycleHooks = registry.get(model.name).get('lifecycleHooks');
|
||||
if (lifecycleHooks.has('_willCreate')) {
|
||||
lifecycleHooks.get('_willCreate').call(record);
|
||||
}
|
||||
/**
|
||||
* Register post processing operation that are to be delayed at
|
||||
* the end of the update cycle.
|
||||
|
||||
@@ -14,25 +14,10 @@ registerModel({
|
||||
name: 'ComposerView',
|
||||
identifyingFields: [['threadView', 'messageViewInEditing', 'chatter']],
|
||||
lifecycleHooks: {
|
||||
_willCreate() {
|
||||
/**
|
||||
* Determines whether there is a mention RPC currently in progress.
|
||||
* Useful to queue a new call if there is already one pending.
|
||||
*/
|
||||
this._hasMentionRpcInProgress = false;
|
||||
/**
|
||||
* Determines the next function to execute after the current mention
|
||||
* RPC is done, if any.
|
||||
*/
|
||||
this._nextMentionRpcFunction = undefined;
|
||||
},
|
||||
_created() {
|
||||
document.addEventListener('click', this.onClickCaptureGlobal, true);
|
||||
},
|
||||
_willDelete() {
|
||||
// Clears the mention queue on deleting the record to prevent
|
||||
// unnecessary RPC.
|
||||
this._nextMentionRpcFunction = undefined;
|
||||
document.removeEventListener('click', this.onClickCaptureGlobal, true);
|
||||
},
|
||||
},
|
||||
@@ -1133,17 +1118,19 @@ registerModel({
|
||||
* @param {function} func
|
||||
*/
|
||||
async _executeOrQueueFunction(func) {
|
||||
if (this._hasMentionRpcInProgress) {
|
||||
this._nextMentionRpcFunction = func;
|
||||
if (this.hasMentionRpcInProgress) {
|
||||
this.update({ nextMentionRpcFunction: func });
|
||||
return;
|
||||
}
|
||||
this._hasMentionRpcInProgress = true;
|
||||
this._nextMentionRpcFunction = undefined;
|
||||
this.update({
|
||||
hasMentionRpcInProgress: true,
|
||||
nextMentionRpcFunction: clear(),
|
||||
});
|
||||
await func();
|
||||
if (this.exists()) {
|
||||
this._hasMentionRpcInProgress = false;
|
||||
if (this._nextMentionRpcFunction) {
|
||||
this._executeOrQueueFunction(this._nextMentionRpcFunction);
|
||||
this.update({ hasMentionRpcInProgress: false });
|
||||
if (this.nextMentionRpcFunction) {
|
||||
this._executeOrQueueFunction(this.nextMentionRpcFunction);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1501,6 +1488,13 @@ registerModel({
|
||||
hasHeader: attr({
|
||||
compute: '_computeHasHeader',
|
||||
}),
|
||||
/**
|
||||
* Determines whether there is a mention RPC currently in progress.
|
||||
* Useful to queue a new call if there is already one pending.
|
||||
*/
|
||||
hasMentionRpcInProgress: attr({
|
||||
default: false,
|
||||
}),
|
||||
hasMentionSuggestionsBelowPosition: attr({
|
||||
compute: '_computeHasMentionSuggestionsBelowPosition',
|
||||
default: false,
|
||||
@@ -1574,6 +1568,11 @@ registerModel({
|
||||
* properly without flicker.
|
||||
*/
|
||||
mirroredTextareaRef: attr(),
|
||||
/**
|
||||
* Determines the next function to execute after the current mention
|
||||
* RPC is done, if any.
|
||||
*/
|
||||
nextMentionRpcFunction: attr(),
|
||||
/**
|
||||
* Determines the label on the send button of this composer view.
|
||||
*/
|
||||
|
||||
@@ -26,19 +26,6 @@ registerModel({
|
||||
*/
|
||||
identifyingFields: ['messaging'],
|
||||
lifecycleHooks: {
|
||||
/**
|
||||
* This function is called during the create cycle, when the record has
|
||||
* already been created, but its values have not yet been assigned.
|
||||
*
|
||||
* It is usually preferable to use @see `_created`.
|
||||
*
|
||||
* The main use case is to prepare the record for the assignation of its
|
||||
* values, for example if a computed field relies on the record to have
|
||||
* some purely technical property correctly set.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_willCreate() {},
|
||||
/**
|
||||
* This function is called after the record has been created, more
|
||||
* precisely at the end of the update cycle (which means all implicit
|
||||
|
||||
Reference in New Issue
Block a user