summaryrefslogtreecommitdiff
path: root/addons/web/static/tests
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2018-03-14 10:09:39 +0100
committerGéry Debongnie <ged@odoo.com>2018-03-14 17:03:11 +0100
commit4fd9db52a26701ca1ae028a8e625beaa0550ea62 (patch)
tree4d49f005ae071f925cac5d757a0d8017a8ee6421 /addons/web/static/tests
parent8df915da05833da138b870a39cf0279090d49eed (diff)
[FIX] web: prevent issues with pager and x2m and limit
When we are in the process of adding a record, we do not want to update the pager count. The reason is that if the user is at the limit (so, 1-40/40, no pager visible), then click on add, there will be a pager shown with 1-40/41. Now, imagine that the record currently being added as a required field, and the user clicks on the pager. In that case, we need to discard the newly added record (bringing the total back to 40), then move to next page, which does not exist anymore. So, to fix this issue, we simply consider that a record being added does not count, from the point of view of the pager.
Diffstat (limited to 'addons/web/static/tests')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js61
1 files changed, 60 insertions, 1 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index dfafb58abd5..5891c5d1515 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -2077,7 +2077,7 @@ QUnit.module('relational_fields', {
data: this.data,
arch: '<form>' +
'<field name="p">' +
- '<tree editable="bttom">' +
+ '<tree editable="bottom">' +
'<field name="trululu"/>' +
'</tree>' +
'</field>' +
@@ -3994,6 +3994,37 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('editable one2many list, pager is updated', function (assert) {
+ assert.expect(1);
+
+ this.data.turtle.records.push({id:4, turtle_foo: 'stephen hawking'});
+ this.data.partner.records[0].turtles = [1,2,3,4];
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<field name="turtles">' +
+ '<tree editable="bottom" limit="3">' +
+ '<field name="turtle_foo"/>' +
+ '</tree>' +
+ '</field>' +
+ '</form>',
+ res_id: 1,
+ });
+
+ // add a record, then click in form view to confirm it
+ form.$buttons.find('.o_form_button_edit').click();
+ form.$('.o_field_x2many_list_row_add a').click();
+ form.$el.click();
+
+ assert.strictEqual(form.$('.o_cp_pager').text().trim(), '1-3 / 5',
+ "pager should display the correct total");
+ form.destroy();
+ });
+
+
QUnit.test('one2many list (non editable): edition', function (assert) {
assert.expect(12);
@@ -4302,6 +4333,34 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('editable one2many list, adding line when only one page', function (assert) {
+ assert.expect(1);
+
+ this.data.partner.records[0].turtles=[1,2,3];
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<field name="turtles">' +
+ '<tree editable="bottom" limit="3">' +
+ '<field name="turtle_foo"/>' +
+ '</tree>' +
+ '</field>' +
+ '</form>',
+ res_id: 1,
+ });
+
+ // add a record, to reach the page size limit
+ form.$buttons.find('.o_form_button_edit').click();
+ form.$('.o_field_x2many_list_row_add a').click();
+
+ // the record currently being added should not count in the pager
+ assert.ok(!form.$('.o_cp_pager').is(':visible'),
+ "pager should not be visible");
+ form.destroy();
+ });
+
QUnit.test('unselecting a line with missing required data', function (assert) {
assert.expect(5);