[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) <mge@openerp.com>
This commit is contained in:
Lucas Perais (lpe)
2019-06-14 13:38:09 +00:00
parent d663ab3345
commit 6a29dec93f
2 changed files with 56 additions and 2 deletions
+3 -2
View File
@@ -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 = {};
}
},
});
+53
View File
@@ -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: '<form string="Partners">' +
'<sheet>' +
'<group>' +
'<field name="message_attachment_count" string="I\'m here"/>' +
'</group>' +
'</sheet>' +
'</form>',
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: '<form string="Partners">' +
'<sheet>' +
'<group>' +
'<field name="message_attachment_count" string="I\'m here"/>' +
'</group>' +
'</sheet>' +
'<div class="oe_chatter">' +
'<field name="message_follower_ids" widget="mail_followers"/>' +
'<field name="message_ids" widget="mail_thread"/>' +
'<field name="activity_ids" widget="mail_activity"/>' +
'</div>' +
'</form>',
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();