[FIX] web: list: multi edit input of date(time) fields
The Date(Time)Fields listen to 'input' and 'change' events (like all InputFields) to keep track of changes. However, the datepicker already listens to the 'change' event. As a consequence, in multi edition in a list view, if the user changed the value of a date(time) field by directly editing the input, the fieldChanged event was triggered twice, and there were 2 dialogs asking the user if he wanted to save the change. This rev. makes the Date(Time)Fields stop listening themselves to 'input' and 'change' events, and instead completely rely on the datepicker widget. Task 2068280
This commit is contained in:
@@ -3540,6 +3540,45 @@ QUnit.module('basic_fields', {
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('multi edition of datetime field in list view: edit date in input', async function (assert) {
|
||||
assert.expect(4);
|
||||
|
||||
var list = await createView({
|
||||
View: ListView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<tree editable="bottom">' +
|
||||
'<field name="datetime"/>' +
|
||||
'</tree>',
|
||||
translateParameters: { // Avoid issues due to localization formats
|
||||
date_format: '%m/%d/%Y',
|
||||
time_format: '%H:%M:%S',
|
||||
},
|
||||
session: {
|
||||
getTZOffset: function () {
|
||||
return 120;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// select two records and edit them
|
||||
await testUtils.dom.click(list.$('.o_data_row:eq(0) .o_list_record_selector input'));
|
||||
await testUtils.dom.click(list.$('.o_data_row:eq(1) .o_list_record_selector input'));
|
||||
|
||||
await testUtils.dom.click(list.$('.o_data_row:first .o_data_cell'));
|
||||
assert.containsOnce(list, 'input.o_datepicker_input');
|
||||
list.$('.o_datepicker_input').val("10/02/2019 09:00:00");
|
||||
await testUtils.dom.triggerEvents(list.$('.o_datepicker_input'), ['change']);
|
||||
|
||||
assert.containsOnce(document.body, '.modal');
|
||||
await testUtils.dom.click($('.modal .modal-footer .btn-primary'));
|
||||
|
||||
assert.strictEqual(list.$('.o_data_row:first .o_data_cell').text(), "10/02/2019 09:00:00");
|
||||
assert.strictEqual(list.$('.o_data_row:nth(1) .o_data_cell').text(), "10/02/2019 09:00:00");
|
||||
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('datetime field remove value', async function (assert) {
|
||||
assert.expect(4);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user