From d228dfe4983e159a909696b79c99379cec5bd102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 31 Aug 2018 16:56:03 +0200 Subject: [PATCH] [FIX] web: correctly find action-related form view ID in calendar When cliking on a calendar cell user is redirected to a form view to create a new record. However if the calendar action gives a specific form view ID it is not taken into account by calendar. Calendar code still handles views as not being a structure holding viewID and type but just an ordered list of items with (view ID, type). This commit fixes that code. One calendar JS test is updated to correctly match the current structure. This commit is linked to task ID 1876795 and PR #26571. --- addons/web/static/src/js/views/calendar/calendar_view.js | 4 ++-- addons/web/static/tests/views/calendar_tests.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/views/calendar/calendar_view.js b/addons/web/static/src/js/views/calendar/calendar_view.js index c770c9eb642..20d358c517c 100644 --- a/addons/web/static/src/js/views/calendar/calendar_view.js +++ b/addons/web/static/src/js/views/calendar/calendar_view.js @@ -125,10 +125,10 @@ var CalendarView = AbstractView.extend({ attrs.form_view_id ? parseInt(attrs.form_view_id, 10) : false; if (!this.controllerParams.formViewId && params.action) { var formViewDescr = _.find(params.action.views, function (v) { - return v[1] === 'form'; + return v.type === 'form'; }); if (formViewDescr) { - this.controllerParams.formViewId = formViewDescr[0]; + this.controllerParams.formViewId = formViewDescr.viewID; } } diff --git a/addons/web/static/tests/views/calendar_tests.js b/addons/web/static/tests/views/calendar_tests.js index 9614350a9f8..54ecdbe07e7 100644 --- a/addons/web/static/tests/views/calendar_tests.js +++ b/addons/web/static/tests/views/calendar_tests.js @@ -2248,7 +2248,7 @@ QUnit.module('Views', { archs: archs, viewOptions: { initialDate: initialDate, - action: {views: [[1, 'kanban'], [43, 'form']]} + action: {views: [{viewID: 1, type: 'kanban'}, {viewID: 43, type: 'form'}]} }, mockRPC: function (route, args) { if (args.method === "create") {