[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.
This commit is contained in:
Thibault Delavallée
2018-09-10 13:08:17 +02:00
parent f099486c0c
commit d228dfe498
2 changed files with 3 additions and 3 deletions
@@ -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;
}
}
@@ -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") {