[FIX] web: use "get_formview_id" when opening record from calendar view
Opening a record in a calendar view always showed the default form view when it is not a popup. Example in CRM: opening an opportunity will always show a lead view. The fix aims to use the "get_formview_id" method to find the right id of the view that must be shown instead of using a default id. opw-774272
This commit is contained in:
@@ -247,13 +247,20 @@ var CalendarController = AbstractController.extend({
|
||||
id = id && parseInt(id).toString() === id ? parseInt(id) : id;
|
||||
|
||||
if (!this.eventOpenPopup) {
|
||||
this.do_action({
|
||||
type: 'ir.actions.act_window',
|
||||
res_id: id,
|
||||
res_model: this.modelName,
|
||||
views: [[this.formViewId || false, 'form']],
|
||||
target: 'current',
|
||||
context: event.context || self.context,
|
||||
this._rpc({
|
||||
model: self.modelName,
|
||||
method: 'get_formview_id',
|
||||
//The event can be called by a view that can have another context than the default one.
|
||||
args: [[id], event.context || self.context],
|
||||
}).then(function (viewId) {
|
||||
self.do_action({
|
||||
type:'ir.actions.act_window',
|
||||
res_id: id,
|
||||
res_model: self.modelName,
|
||||
views: [[viewId || false, 'form']],
|
||||
target: 'current',
|
||||
context: event.context || self.context,
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -975,6 +975,12 @@ QUnit.module('Views', {
|
||||
viewOptions: {
|
||||
initialDate: initialDate,
|
||||
},
|
||||
mockRPC: function (route, args) {
|
||||
if (args.method === "get_formview_id") {
|
||||
return $.Deferred().resolve('A view');
|
||||
}
|
||||
return this._super(route, args);
|
||||
},
|
||||
});
|
||||
|
||||
// click on an existing event to open the form view
|
||||
@@ -985,7 +991,7 @@ QUnit.module('Views', {
|
||||
type: "ir.actions.act_window",
|
||||
res_id: 4,
|
||||
res_model: "event",
|
||||
views: [[false, "form"]],
|
||||
views: [['A view', "form"]],
|
||||
target: "current",
|
||||
context: {}
|
||||
},
|
||||
@@ -1103,6 +1109,12 @@ QUnit.module('Views', {
|
||||
viewOptions: {
|
||||
initialDate: initialDate,
|
||||
},
|
||||
mockRPC: function (route, args) {
|
||||
if (args.method === "get_formview_id") {
|
||||
return $.when(false);
|
||||
}
|
||||
return this._super(route, args);
|
||||
},
|
||||
});
|
||||
|
||||
assert.strictEqual(calendar.$('.fc-resizer').length, 0, "should not have resize button");
|
||||
|
||||
Reference in New Issue
Block a user