[FIX] web: fix form resequence test e61639723

In 12.3 when lines are resequenced, the position of the current line
does not take into account that it could have been changed (because of
drag and dropping a line before or after).

opw-1966589
closes #33878
This commit is contained in:
Nicolas Lempereur
2019-06-04 15:09:44 +00:00
committed by Christophe Simonis
parent a89a7b30a4
commit bbc8c9fc26
2 changed files with 15 additions and 6 deletions
@@ -911,6 +911,11 @@ ListRenderer.include({
_resequence: function (event, ui) {
var self = this;
var movedRecordID = ui.item.data('id');
// update currentID taking moved line into account
if (this.currentRow !== null) {
var currentID = self.state.data[self.currentRow].id;
this.currentRow = this._getRow(currentID).index();
}
self.unselectRow().then(function () {
var rows = self.state.data;
var row = self._getRecord(movedRecordID);
+10 -6
View File
@@ -8119,16 +8119,18 @@ QUnit.module('Views', {
assert.strictEqual(form.$('[name="foo"]').val(), "0", "onchange worked there is 0 line");
// Add one line
form.$('.o_field_x2many_list_row_add a').click();
await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
form.$('.o_field_one2many input:first').focus();
await testUtils.nextTick();
form.$('.o_field_one2many input:first').val('first line').trigger('input');
form.$('input[name="foo"]').click();
await testUtils.nextTick();
await testUtils.dom.click(form.$('input[name="foo"]'));
assert.strictEqual(onchangeNum, 2, "one onchange happens when a line is added");
assert.strictEqual(form.$('[name="foo"]').val(), "1", "onchange worked there is 1 line");
// Drag and drop second line before first one (with 1 draft and invalid line)
form.$('.o_field_x2many_list_row_add a').click();
await testUtils.dragAndDrop(
await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
await testUtils.dom.dragAndDrop(
form.$('.ui-sortable-handle').eq(0),
form.$('.o_data_row').last(),
{position: 'bottom'}
@@ -8137,10 +8139,12 @@ QUnit.module('Views', {
assert.strictEqual(form.$('[name="foo"]').val(), "1", "onchange worked there is 1 line");
// Add a second line
form.$('.o_field_x2many_list_row_add a').click();
await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
form.$('.o_field_one2many input:first').focus();
await testUtils.nextTick();
form.$('.o_field_one2many input:first').val('second line').trigger('input');
form.$('input[name="foo"]').click();
await testUtils.nextTick();
await testUtils.dom.click(form.$('input[name="foo"]'));
assert.strictEqual(onchangeNum, 4, "one onchange happens when a line is added");
assert.strictEqual(form.$('[name="foo"]').val(), "2", "onchange worked there is 2 lines");