summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2018-03-14 12:04:46 +0100
committerGéry Debongnie <ged@odoo.com>2018-03-14 17:03:23 +0100
commit7287c672f54126781854fea2412e50fbf9702bc3 (patch)
treeacccd281ae77962a35992c988bc8be699c8c9edc /addons/web/static/tests/fields
parent4586b876f273181b57f3f3fe4b0dce2a2d26b27a (diff)
[FIX] web: x2m: properly reset limit/offset to initial value
When we discard an element, we want to make sure that the new state is not corrupted by previous user operations. In our case, we possibly had a limit and an offset values modified by the user. This could lead to unpleasant situations, with incorrect data displayed on the form view. Note that this actually fixes a new bug introduced by commit https://github.com/odoo/odoo/commit/e7fab234201e357da52c3576ad2e8fc9ceee9359 (this is the commit that introduces the tempLimitIncrement attribute)
Diffstat (limited to 'addons/web/static/tests/fields')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index 8aeca04a509..a4292d64a6c 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -4361,6 +4361,39 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('editable one2many list, adding line, then discarding', 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 discard
+ form.$buttons.find('.o_form_button_edit').click();
+ form.$('.o_field_x2many_list_row_add a').click();
+ form.$buttons.find('.o_form_button_cancel').click();
+
+ // confirm the discard operation
+ $('.modal .modal-footer .btn-primary').click(); // click on confirm
+
+ assert.strictEqual(form.$('.o_cp_pager').text().trim(), '1-3 / 4',
+ "pager should still be visible");
+ form.destroy();
+ });
+
QUnit.test('editable one2many list, required field and pager', function (assert) {
assert.expect(1);
@@ -4438,6 +4471,47 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('editable one2many list, adding, discarding, and pager', function (assert) {
+ assert.expect(2);
+
+ this.data.partner.records[0].turtles = [1];
+
+ 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 4 records record (to make the pager appear)
+ form.$buttons.find('.o_form_button_edit').click();
+ form.$('.o_field_x2many_list_row_add a').click();
+ form.$('.o_field_x2many_list_row_add a').click();
+ form.$('.o_field_x2many_list_row_add a').click();
+ form.$('.o_field_x2many_list_row_add a').click();
+
+ // go on next page
+ form.$('.o_pager_next').click();
+
+ // discard
+ form.$buttons.find('.o_form_button_cancel').click();
+ $('.modal .modal-footer .btn-primary').click();
+
+ assert.strictEqual(form.$('tr.o_data_row').length, 1,
+ "should have 1 data row");
+ 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);