From 078b31dc7f67f3893bcbe5a3b76936490add0e38 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Tue, 2 Oct 2018 13:08:18 +0000 Subject: [FIX] web: Make datetimepicker configurable in datetime fields The datetimepicker option was introduced to be able to customize the datetime picker widget in date/datetime fields. However, due to the way the _makeDatePicker function was coded, it did not work in datetime fields. Thank to Yajo for the initial fix closes odoo/odoo#27541 --- .../web/static/tests/fields/basic_fields_tests.js | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'addons/web/static/tests/fields') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 1133bed08b5..eab68f08207 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -2556,6 +2556,33 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('datepicker option: daysOfWeekDisabled', function (assert) { + assert.expect(2); + + this.data.partner.fields.datetime.default = "2017-08-02 12:00:05"; + this.data.partner.fields.datetime.required = true; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'
' + + '' + + '', + res_id: 1, + }); + + form.$buttons.find('.o_form_button_create').click(); + form.$('.o_datepicker_input.o_input').click(); + assert.ok($('.day:last-child(),.day:nth-child(2)').hasClass('disabled'), + 'first and last days must be disabled'); + assert.notOk($('.day:not(:last-child()):not(:nth-child(2))').hasClass('disabled'), + 'other days must stay clickable'); + + form.destroy(); + }); + QUnit.module('FieldMonetary'); QUnit.test('monetary field in form view', function (assert) { -- cgit v1.2.3 From 8445baa08d4f7cdbe60555ef1ff691a37e99d900 Mon Sep 17 00:00:00 2001 From: Mohammed Shekha Date: Fri, 31 Aug 2018 17:51:31 +0530 Subject: [FIX]web: do not crash when dismissing a modal with escape stopPropagation of navigation_move event for where direction=cancel, currently if navigation_move event throws error when user press escape in dialog where dialog is opened from editable list record Scenario: Install website_sale -> Open Product form(variant enable) -> open variant tab -> open Attribute m2o form popup and press Escape on dialog Result: Error Expected: It should close dialog and keep editable list view record open, btw m2o field should also be focused when dialog is closed but that's another issue, will be fixed in another ongoing task Related to Issue: #1873919 Co-authored-by: Vincent Schippefilt Co-authored-by: Mohammed Shekha --- .../static/tests/fields/relational_fields_tests.js | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'addons/web/static/tests/fields') diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index b68ac239c13..cebe9102551 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -12758,6 +12758,59 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('when creating a new many2one on a x2many then discarding it immediately with ESCAPE, it should not crash', function (assert) { + var done = assert.async(); + assert.expect(1); + + this.data.partner.records[0].turtles = []; + + var form = createView({ + View: FormView, + model: 'partner', + viewOptions: { + mode: 'edit', + }, + data: this.data, + arch:'
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
', + res_id: 1, + archs: { + 'partner,false,form': '
' + }, + }); + + // add a new line + form.$el.find('.o_field_x2many_list_row_add>a').click(); + + // open the field turtle_trululu (one2many) + var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY; + relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = 0; + form.$el.find('.o_input_dropdown>input').click(); + + concurrency.delay(0).then(function () { + // click create and edit + $('.ui-autocomplete .ui-menu-item a:contains(Create and)').trigger('mouseenter').click(); + + // hit escape immediately + var escapeKey = $.ui.keyCode.ESCAPE; + $(document.activeElement).trigger( + $.Event('keydown', {which: escapeKey, keyCode: escapeKey})); + + assert.ok('did not crash'); + relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY; + form.destroy(); + done(); + }); + }); + }); }); }); -- cgit v1.2.3 From 57ae9428b47a7ce6cdb75115a62fc268e4af7770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Fri, 12 Oct 2018 12:45:38 +0000 Subject: [FIX] web: prevent URL click from opening a record If we click on a link, we only want to open the URL, and not the record when the button is on a list. PR: #27230 --- .../static/tests/fields/relational_fields_tests.js | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'addons/web/static/tests/fields') diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 53a3399c9b8..49b868c6edb 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -9665,6 +9665,37 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('click on URL should not open the record', function (assert) { + assert.expect(2); + + this.data.partner.records[0].turtles = [1]; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'
' + + '' + + '' + + '' + + '' + + '' + + '' + + '
' + + '', + res_id: 1, + }); + + form.$('.o_email_cell a').click(); + assert.strictEqual($('.modal .o_form_view').length, 0, + 'click should not open the modal'); + + form.$('.o_url_cell a').click(); + assert.strictEqual($('.modal .o_form_view').length, 0, + 'click should not open the modal'); + form.destroy(); + }); + QUnit.module('FieldMany2Many'); QUnit.test('many2many kanban: edition', function (assert) { -- cgit v1.2.3 From cba5f7a98f3644694eadc51c76ba080724879b28 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Mon, 8 Oct 2018 16:37:24 +0200 Subject: [FIX] web: fetch dependency fields in x2many Image field widget need the __last_update field alongside them for caching purposes, though that field should never be present explicitly in the views Before this commit, the dependencies of field widgets were not merged into the model's fields definition, creating a traceback when adding an image field widget into a x2many list After this commit, there is no traceback and the image field works properly closes #27545 --- .../web/static/tests/fields/basic_fields_tests.js | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'addons/web/static/tests/fields') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 4ef08c02999..98468872ab9 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1852,6 +1852,40 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('image fields in x2many list are loaded correctly', function (assert) { + assert.expect(2); + + this.data.partner_type.fields.image = {name: 'image', type: 'binary'}; + this.data.partner_type.records[0].image = 'product_image'; + this.data.partner.records[0].timmy = [12]; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '' + + '' + + '' + + '' + + '
', + res_id: 1, + mockRPC: function (route, args) { + if (route === 'data:image/png;base64,product_image') { + assert.ok(true, "The list's image should have been fetched"); + return $.when(); + } + return this._super.apply(this, arguments); + }, + }); + + assert.strictEqual(form.$('tr.o_data_row').length, 1, + 'There should be one record in the many2many'); + + form.destroy(); + }); + QUnit.test('image fields with required attribute', function (assert) { assert.expect(2); -- cgit v1.2.3 From f249c5ef2a3242952e4c13b0ebca2e72f40ae064 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Wed, 10 Oct 2018 11:29:49 +0000 Subject: [FIX] web: restore broken datepicker input behavior In Firefox, the input behavior and visual representation (navigation, caret placement, value selection, etc.) was broken when using a datepicker (easily reproductible on date and datetime widgets). This was due to the `focus` event being stopped on the input, which doesn't seem to be correctly supported by Firefox. The deleted code was supposed to toggle the picker when the field was clicked (see odoo/odoo@89093a1) (toggle on click and disable focus) but the lib correctly supports on focus without extra code. This also fixes the fact that the datepicker was not open on focus (only on clicked). In some tests where the field was the first in the form view, it is now correctly autofocused. Forward-port: not useful from 12.0 because the code has changed with BS4 and this has already been applied in odoo/odoo@6692919 and odoo/odoo@c63630d. Closes #23438 closes odoo/odoo#27657 --- addons/web/static/tests/fields/basic_fields_tests.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'addons/web/static/tests/fields') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index eab68f08207..df16f5b393f 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -2045,7 +2045,7 @@ QUnit.module('basic_fields', { }); QUnit.test('date field value should not set on first click', function (assert) { - assert.expect(2); + assert.expect(3); var form = createView({ View: FormView, @@ -2055,10 +2055,10 @@ QUnit.module('basic_fields', { res_id: 4, }); form.$buttons.find('.o_form_button_edit').click(); - form.$('.o_datepicker_input').click(); + assert.strictEqual($('.bootstrap-datetimepicker-widget').length, 1, "there should be a datepicker (autofocus)"); assert.strictEqual(form.$('.o_datepicker_input').val(), '', "date field's input should be empty on first click"); $('.day:contains(22)').click(); - form.$('.o_datepicker_input').click(); // Open Datepicker second time + form.$('.o_datepicker_input').focus(); // Open Datepicker second time assert.strictEqual($('.day.active').text(), '22', 'datepicker should be highlight with 22nd day of month'); form.destroy(); }); @@ -2096,8 +2096,7 @@ QUnit.module('basic_fields', { assert.strictEqual(form.$('.o_datepicker_input').val(), '02/03/2017', 'the date should be correct in edit mode'); - // click on the input and select another value - form.$('.o_datepicker_input').click(); + // select another value assert.ok($('.bootstrap-datetimepicker-widget').length, 'datepicker should be open'); assert.strictEqual($('.day.active').data('day'), '02/03/2017', 'datepicker should be highlight February 3'); $('.bootstrap-datetimepicker-widget .picker-switch').first().click(); // Month selection @@ -2180,8 +2179,7 @@ QUnit.module('basic_fields', { assert.strictEqual(list.$('input.o_datepicker_input').val(), '02/03/2017', 'the date should be correct in edit mode'); - // click on the input and select another value - list.$('input.o_datepicker_input').click(); + // select another value assert.ok($('.bootstrap-datetimepicker-widget').length, 'datepicker should be open'); $('.bootstrap-datetimepicker-widget .picker-switch').first().click(); // Month selection $('.bootstrap-datetimepicker-widget .picker-switch').first().click(); // Year selection @@ -2298,8 +2296,7 @@ QUnit.module('basic_fields', { form.$buttons.find('.o_form_button_edit').click(); assert.strictEqual(form.$('.o_datepicker_input').val(), expectedDateString, 'the datetime should be correct in edit mode'); - // click on the input and select 22 February at 8:23:33 - form.$('.o_datepicker_input').click(); + // select 22 February at 8:23:33 assert.ok($('.bootstrap-datetimepicker-widget').length, 'datepicker should be open'); $('.bootstrap-datetimepicker-widget .picker-switch').first().click(); // Month selection $('.bootstrap-datetimepicker-widget .picker-switch').first().click(); // Year selection @@ -2397,8 +2394,7 @@ QUnit.module('basic_fields', { assert.strictEqual(list.$('input.o_datepicker_input').val(), expectedDateString, 'the date should be correct in edit mode'); - // click on the input and select 22 February at 8:23:33 - list.$('input.o_datepicker_input').click(); + // select 22 February at 8:23:33 assert.ok($('.bootstrap-datetimepicker-widget').length, 'datepicker should be open'); $('.bootstrap-datetimepicker-widget .picker-switch').first().click(); // Month selection $('.bootstrap-datetimepicker-widget .picker-switch').first().click(); // Year selection @@ -2574,7 +2570,6 @@ QUnit.module('basic_fields', { }); form.$buttons.find('.o_form_button_create').click(); - form.$('.o_datepicker_input.o_input').click(); assert.ok($('.day:last-child(),.day:nth-child(2)').hasClass('disabled'), 'first and last days must be disabled'); assert.notOk($('.day:not(:last-child()):not(:nth-child(2))').hasClass('disabled'), -- cgit v1.2.3 From 32b19115e9d7470531f3218b39e8773ba5361bba Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 10 Oct 2018 18:50:37 +0200 Subject: [FIX] web,mrp: move test to adequate module --- .../web/static/tests/fields/basic_fields_tests.js | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'addons/web/static/tests/fields') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 5b36b433a05..03f9a3606af 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -10,6 +10,7 @@ var KanbanView = require('web.KanbanView'); var ListView = require('web.ListView'); var session = require('web.session'); var testUtils = require('web.test_utils'); +var field_registry = require('web.field_registry'); var createView = testUtils.createView; var DebouncedField = basicFields.DebouncedField; @@ -1653,6 +1654,49 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test("pdf_viewer: upload rendering", function (assert) { + assert.expect(6); + + testUtils.patch(field_registry.map.pdf_viewer, { + on_file_change: function (ev) { + ev.target = {files: [new Blob()]}; + this._super.apply(this, arguments); + }, + _getURI: function (fileURI) { + var res = this._super.apply(this, arguments); + assert.step('_getURI'); + assert.ok(_.str.startsWith(fileURI, 'blob:')); + this.PDFViewerApplication = { + open: function (URI) { + assert.step('open'); + assert.ok(_.str.startsWith(URI, 'blob:')); + }, + }; + return 'about:blank'; + }, + }); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: + '
' + + '' + + '', + }); + + // first upload initialize iframe + form.$('input[type="file"]').trigger('change'); + assert.verifySteps(['_getURI']); + // second upload call pdfjs method inside iframe + form.$('input[type="file"]').trigger('change'); + assert.verifySteps(['_getURI', 'open']); + + testUtils.unpatch(field_registry.map.pdf_viewer); + form.destroy(); + }); + QUnit.test('text field rendering in list view', function (assert) { assert.expect(1); -- cgit v1.2.3