From ddb8fc1f628433e40ae3196115f7b9a11e5b5254 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Mon, 29 Apr 2019 15:15:35 +0000 Subject: [FIX] web: checkbox in favorites menu: don't close on click Following f4fbaf1efae11e8bd3b1a2938ab765d391764a1b which changes the label/checkbox structure into: ```
``` So, before this commit, there may have been multiple input with the same Id. The consequence is that, when clicking on a label, the browser would take the first Id it found which was erroneous, because all checkboxes in Favorites menu had the same Id In reality, the use case goes as: - open a x2m, - search more - Favorites > Save current search > click on one the two checkboxes > The dropdown closed, without checking the box After this commit, when clicking on the checkbox in the favorites menu the checkbox is toggled and the dropdown stays. Also, the checkboxed have now unique ids OPW 1974587 closes odoo/odoo#33032 Signed-off-by: Lucas Perais (lpe) --- addons/web/static/tests/views/search_view_tests.js | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'addons/web/static/tests/views') diff --git a/addons/web/static/tests/views/search_view_tests.js b/addons/web/static/tests/views/search_view_tests.js index 3e1070c4088..6281236e74b 100644 --- a/addons/web/static/tests/views/search_view_tests.js +++ b/addons/web/static/tests/views/search_view_tests.js @@ -3,6 +3,7 @@ odoo.define('web.search_view_tests', function (require) { var FormView = require('web.FormView'); var testUtils = require('web.test_utils'); +var testUtilsDom = require('web.test_utils_dom'); var createActionManager = testUtils.createActionManager; var patchDate = testUtils.patchDate; var createView = testUtils.createView; @@ -1007,7 +1008,7 @@ QUnit.module('Search View', { }); QUnit.test('Customizing filter does not close the filter dropdown', function (assert) { - assert.expect(4); + assert.expect(6); var self = this; _.each(this.data.partner.records.slice(), function (rec) { @@ -1031,6 +1032,13 @@ QUnit.module('Search View', { 'partner,false,search': '', }, res_id: 1, + intercepts: { + create_filter: function (ev) { + var data = ev.data; + assert.strictEqual(data.filter.name, 'Fire on the bayou'); + assert.strictEqual(data.filter.is_default, true); + }, + }, }); form.$('.o_input').click(); @@ -1061,9 +1069,21 @@ QUnit.module('Search View', { $input.click(); $input.click(); }); - assert.ok($filterDropDown.is(':visible')); + // Favorites Menu + testUtilsDom.click($modal.find('.o_search_options button:contains(Favorites)')); + testUtilsDom.click($modal.find('.o_favorites_menu a:contains(Save current search)')); + $modal.find('.o_search_options .dropdown-menu').one('click', function (ev) { + // This handler is on the webClient + // But since the test suite doesn't have one + // We manually set it here + ev.stopPropagation(); + }); + $modal.find('.o_save_name:first input').val('Fire on the bayou'); + testUtilsDom.click($modal.find('.o_save_name label:contains(Use by default)')); + testUtilsDom.click($modal.find('.o_save_name button:contains(Save)')); + form.destroy(); }); -- cgit v1.2.3 From d809b476819968837b61bdd78fbf101caac73adc Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 6 May 2019 15:11:35 +0000 Subject: [FIX] web: month view drop - Install the 'Maintenance' app - Create a maintenance request, set a day and a duration of 6 hours - Go the calendar view, month mode - Move the maintenance request from one day to another The duration is changed with a non-sense value. In month mode, the hours are not represented in the calendar so it is not possible to compute the `date_delay`. Moreover, when a record is moved from one date to another (`_onDropRecord`) in month mode, there is actually no point recomputing the duration; the `date_start` is enough. Note that `date_delay` is used (at the time of writing) in 2 views and absolutely not tested. opw-1984637 closes odoo/odoo#33193 Signed-off-by: Nicolas Martinelli (nim) --- addons/web/static/tests/views/calendar_tests.js | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'addons/web/static/tests/views') diff --git a/addons/web/static/tests/views/calendar_tests.js b/addons/web/static/tests/views/calendar_tests.js index ae8184dc7e8..e97845ea7e4 100644 --- a/addons/web/static/tests/views/calendar_tests.js +++ b/addons/web/static/tests/views/calendar_tests.js @@ -44,6 +44,7 @@ QUnit.module('Views', { stop_date: {string: "stop date", type: "date"}, start: {string: "start datetime", type: "datetime"}, stop: {string: "stop datetime", type: "datetime"}, + delay: {string: "delay", type: "float"}, allday: {string: "allday", type: "boolean"}, partner_ids: {string: "attendees", type: "one2many", relation: 'partner', default: [[6, 0, [1]]]}, type: {string: "type", type: "integer"}, @@ -2393,6 +2394,49 @@ QUnit.module('Views', { calendar.destroy(); }); + QUnit.test('drag and drop on month mode with date_start and date_delay', function (assert) { + assert.expect(1); + + var calendar = createView({ + View: CalendarView, + model: 'event', + data: this.data, + arch: + ''+ + ''+ + ''+ + ''+ + '', + archs: archs, + viewOptions: { + initialDate: initialDate, + }, + mockRPC: function (route, args) { + if (args.method === "write") { + // delay should not be written at drag and drop + assert.equal(args.args[1].delay, undefined) + } + return this._super(route, args); + }, + }); + + // Create event (on 20 december) + var $cell = calendar.$('.fc-day-grid .fc-row:eq(3) .fc-day:eq(2)'); + testUtils.triggerMouseEvent($cell, "mousedown"); + testUtils.triggerMouseEvent($cell, "mouseup"); + var $input = $('.modal-body input:first'); + $input.val("An event").trigger('input'); + $('.modal button.btn:contains(Create)').trigger('click'); + + // Move event to another day (on 27 november) + testUtils.dragAndDrop( + calendar.$('.fc-event').first(), + calendar.$('.fc-day-top').first() + ); + + calendar.destroy(); + }); + QUnit.test('form_view_id attribute works (for creating events)', function (assert) { assert.expect(1); -- cgit v1.2.3