summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/models/model/model.js
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-08-10 10:39:36 +0000
committerSébastien Theys <seb@odoo.com>2020-08-21 14:16:33 +0000
commit79f6b15c747a7ce9bf3d3415c569feda4da85323 (patch)
tree1ad8fbe037963cf40d52db5fbe0ad6aaa8646410 /addons/mail/static/src/models/model/model.js
parent01aa711d413040af5edc9cb872e72a500cfa641d (diff)
[FIX] mail: avoid unnecessary update of inverse in JS models
Part of task-2308312 X-original-commit: 0e08e43decf18108d25d051ad76c093bcdf434db
Diffstat (limited to 'addons/mail/static/src/models/model/model.js')
-rw-r--r--addons/mail/static/src/models/model/model.js46
1 files changed, 38 insertions, 8 deletions
diff --git a/addons/mail/static/src/models/model/model.js b/addons/mail/static/src/models/model/model.js
index be02afeeaee..f700b330a93 100644
--- a/addons/mail/static/src/models/model/model.js
+++ b/addons/mail/static/src/models/model/model.js
@@ -30,14 +30,44 @@ function factory() {
}
/**
- * Called when the record is being created, but not yet processed
- * its create value on the fields. This method is handy to define purely
- * technical property on this record, like handling of timers. This
- * method acts like the constructor, but has a very important difference:
- * the `this` is the proxified record, so evaluation of field values
- * on get/set work correctly.
- */
- init() {}
+ * 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 override @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.
+ *
+ * @abstract
+ * @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
+ * changes such as computes have been applied too).
+ *
+ * The main use case is to register listeners on the record.
+ *
+ * @abstract
+ * @private
+ */
+ _created() {}
+
+ /**
+ * This function is called when the record is about to be deleted. The
+ * record still has all of its fields values accessible, but for all
+ * intents and purposes the record should already be considered
+ * deleted, which means update shouldn't be called inside this method.
+ *
+ * The main use case is to unregister listeners on the record.
+ *
+ * @abstract
+ * @private
+ */
+ _willDelete() {}
//----------------------------------------------------------------------
// Public