From 6a29dec93f5245fbfa490481edf17f3d46c295df Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Fri, 14 Jun 2019 12:33:27 +0000 Subject: [PATCH] [FIX] mail: message_attachment_count can be explicit in form view Before this commit, it was not possible to have the field message_attachment_count explicitly defined in the form view. It crashed inelegantly if it were the case After this commit, it is possible to have that field in the form view OPW 1998503 closes odoo/odoo#34143 Signed-off-by: Martin Geubelle (mge) --- addons/mail/static/src/js/form_view.js | 5 ++- addons/mail/static/tests/chatter_tests.js | 53 +++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/js/form_view.js b/addons/mail/static/src/js/form_view.js index 0e1623d0dcf..6a2a41091aa 100644 --- a/addons/mail/static/src/js/form_view.js +++ b/addons/mail/static/src/js/form_view.js @@ -16,8 +16,9 @@ FormView.include({ init: function () { this._super.apply(this, arguments); - if ('message_ids' in this.fieldsInfo[this.viewType]) { - this.fieldsInfo[this.viewType].message_attachment_count = {}; + var fieldsInfo = this.fieldsInfo[this.viewType]; + if ('message_ids' in fieldsInfo && !('message_attachment_count' in fieldsInfo)) { + fieldsInfo.message_attachment_count = {}; } }, }); diff --git a/addons/mail/static/tests/chatter_tests.js b/addons/mail/static/tests/chatter_tests.js index e13d5f18202..ee94f89a86e 100644 --- a/addons/mail/static/tests/chatter_tests.js +++ b/addons/mail/static/tests/chatter_tests.js @@ -223,6 +223,59 @@ QUnit.test('basic rendering', function (assert) { form.destroy(); }); +QUnit.test('basic rendering: message_attachment_count can be in view standalone', function (assert) { + assert.expect(1); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + services: this.services, + arch: '
' + + '' + + '' + + '' + + '' + + '' + + '
', + res_id: 2, + }); + + assert.strictEqual(form.$('.o_form_label').text(), "I'm here", + "The field message_attachment_count must be present according to the view's specs"); + + form.destroy(); +}); + +QUnit.test('basic rendering: message_attachment_count can be in view with chatter', function (assert) { + assert.expect(1); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + services: this.services, + arch: '
' + + '' + + '' + + '' + + '' + + '' + + '
' + + '' + + '' + + '' + + '
' + + '
', + res_id: 2, + }); + + assert.strictEqual(form.$('.o_form_label').text(), "I'm here", + "The field message_attachment_count must be present according to the view's specs"); + + form.destroy(); +}); + QUnit.test('Activity Done keep feedback on blur', function (assert) { assert.expect(3); var done = assert.async();