summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorMartin Geubelle <mge@odoo.com>2017-11-17 15:26:49 +0100
committerMartin Geubelle <mge@odoo.com>2017-11-17 16:26:45 +0100
commitafc0df5b0cddf9ff6381cfa886b40ff08c0d2909 (patch)
treeaf2d5c1b343c57afdc7b393eada28d3d21462bc3 /addons
parent0fdf2913052eecd426be6515d8f77cbd176dcee1 (diff)
[REF] mail: create separate files for includes
The rev. odoo/odoo@ab900bb fixes an issue in mail which needed an include on BasicModel and FormController. As this rev. has been done in a stable branch, the includes have been done in an existing file. This rev. correctly separates the includes in different files.
Diffstat (limited to 'addons')
-rw-r--r--addons/mail/static/src/js/basic_model.js33
-rw-r--r--addons/mail/static/src/js/form_controller.js31
-rw-r--r--addons/mail/static/src/js/form_renderer.js49
-rw-r--r--addons/mail/views/mail_templates.xml2
4 files changed, 66 insertions, 49 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;
+ },
+});
+
+});
diff --git a/addons/mail/static/src/js/form_controller.js b/addons/mail/static/src/js/form_controller.js
new file mode 100644
index 00000000000..b8cb5ab1c25
--- /dev/null
+++ b/addons/mail/static/src/js/form_controller.js
@@ -0,0 +1,31 @@
+
+odoo.define('mail.form_controller', function (require) {
+"use strict";
+
+var FormController = require('web.FormController');
+
+/**
+ * Include the FormController to update the datapoint on the model when a
+ * message is posted.
+ */
+FormController.include({
+ custom_events: _.extend({}, FormController.prototype.custom_events, {
+ new_message: '_onNewMessage',
+ }),
+
+ //--------------------------------------------------------------------------
+ // Handlers
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ * @param {OdooEvent} event
+ * @param {string} event.data.id datapointID
+ * @param {integer[]} event.data.msgIDs list of message ids
+ */
+ _onNewMessage: function (event) {
+ this.model.updateMessageIDs(event.data.id, event.data.msgIDs);
+ },
+});
+
+});
diff --git a/addons/mail/static/src/js/form_renderer.js b/addons/mail/static/src/js/form_renderer.js
index 4a0d98da4df..bc77fc5acab 100644
--- a/addons/mail/static/src/js/form_renderer.js
+++ b/addons/mail/static/src/js/form_renderer.js
@@ -1,9 +1,7 @@
odoo.define('mail.form_renderer', function (require) {
"use strict";
-var BasicModel = require('web.BasicModel');
var Chatter = require('mail.Chatter');
-var FormController = require('web.FormController');
var FormRenderer = require('web.FormRenderer');
/**
@@ -92,51 +90,4 @@ FormRenderer.include({
},
});
-/**
- * Include the FormController and BasicModel to update the datapoint on the
- * model when a message is posted.
- */
-FormController.include({
- custom_events: _.extend({}, FormController.prototype.custom_events, {
- new_message: '_onNewMessage',
- }),
-
- //--------------------------------------------------------------------------
- // Handlers
- //--------------------------------------------------------------------------
-
- /**
- * @private
- * @param {OdooEvent} event
- * @param {string} event.data.id datapointID
- * @param {integer[]} event.data.msgIDs list of message ids
- */
- _onNewMessage: function (event) {
- this.model.updateMessageIDs(event.data.id, event.data.msgIDs);
- },
-});
-
-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;
- },
-});
-
});
diff --git a/addons/mail/views/mail_templates.xml b/addons/mail/views/mail_templates.xml
index 63c403ba637..8c4ab97754b 100644
--- a/addons/mail/views/mail_templates.xml
+++ b/addons/mail/views/mail_templates.xml
@@ -15,7 +15,9 @@
<script type="text/javascript" src="/mail/static/src/js/chatter.js"></script>
<script type="text/javascript" src="/mail/static/src/js/chatter_composer.js"></script>
<script type="text/javascript" src="/mail/static/src/js/followers.js"></script>
+ <script type="text/javascript" src="/mail/static/src/js/form_controller.js"></script>
<script type="text/javascript" src="/mail/static/src/js/form_renderer.js"></script>
+ <script type="text/javascript" src="/mail/static/src/js/basic_model.js"></script>
<script type="text/javascript" src="/mail/static/src/js/basic_view.js"></script>
<script type="text/javascript" src="/mail/static/src/js/thread.js"></script>
<script type="text/javascript" src="/mail/static/src/js/thread_field.js"></script>