summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/basic_model.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail/static/src/js/basic_model.js')
-rw-r--r--addons/mail/static/src/js/basic_model.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/addons/mail/static/src/js/basic_model.js b/addons/mail/static/src/js/basic_model.js
new file mode 100644
index 00000000000..11139819a60
--- /dev/null
+++ b/addons/mail/static/src/js/basic_model.js
@@ -0,0 +1,33 @@
+odoo.define('mail.basic_model', function (require) {
+"use strict";
+
+var BasicModel = require('web.BasicModel');
+
+/**
+ * Include the BasicModel to update the datapoint on the model when a
+ * message is posted.
+ */
+BasicModel.include({
+
+ //--------------------------------------------------------------------------
+ // Public
+ //--------------------------------------------------------------------------
+
+ /**
+ * Update the message ids on a datapoint.
+ *
+ * Note that we directly update the res_ids on the datapoint as the message
+ * has already been posted ; this change can't be handled 'normally' with
+ * x2m commands because the change won't be saved as a normal field.
+ *
+ * @param {string} id
+ * @param {integer[]} msgIDs
+ */
+ updateMessageIDs: function (id, msgIDs) {
+ var element = this.localData[id];
+ element.res_ids = msgIDs;
+ element.count = msgIDs.length;
+ },
+});
+
+});