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();