[FIX] web: allow widget many2many_tags to display more than 40 records

Before this commit, the widget many2many_tags only loaded the first 40
records. This was difficult to see, because there were not so many views
with a lot of tags.
This commit is contained in:
Géry Debongnie
2017-10-12 16:15:06 +02:00
parent 66b692a5eb
commit d4cf4374d1
2 changed files with 25 additions and 1 deletions
@@ -253,7 +253,8 @@ var AbstractView = Class.extend({
return;
}
attrs.limit = attrs.mode === "tree" ? 80 : 40;
attrs.limit = attrs.mode === "tree" ? 80 :
(attrs.widget === 'many2many_tags' ? 1000 : 40);
if (attrs.Widget.prototype.useSubview && !attrs.__no_fetch && !attrs.views[attrs.mode]) {
var context = {};
@@ -7451,6 +7451,29 @@ QUnit.module('relational_fields', {
form.destroy();
});
QUnit.test('many2many_tags can load more than 40 records', function (assert) {
assert.expect(1);
this.data.partner.fields.partner_ids = {string: "Partner", type: "many2many", relation: 'partner'};
this.data.partner.records[0].partner_ids = [];
for (var i = 15; i < 115; i++) {
this.data.partner.records.push({id: i, display_name: 'walter' + i});
this.data.partner.records[0].partner_ids.push(i);
}
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form string="Partners">' +
'<field name="partner_ids" widget="many2many_tags"/>' +
'</form>',
res_id: 1,
});
assert.strictEqual(form.$('.o_field_widget[name="partner_ids"] > span').length, 100,
'should have rendered 100 tags');
form.destroy();
});
QUnit.test('field many2many_tags keeps focus when being edited', function (assert) {
assert.expect(7);