[FIX] web: Prevent 'load_views' caused by default values inside the context
The use case is the following: - Create a kanban view - Customize it to open a form view on the right when clicking on a kanban card - The form view is initialized using the context with a 'default_...' key to set a field. => Since the context is different every time, the 'load_views' rpc call is always triggered, leading to performance issues. Task: 2555114 Part-of: odoo/odoo#91448
This commit is contained in:
@@ -74,7 +74,8 @@ export const viewService = {
|
||||
loadViewsOptions.mobile = true;
|
||||
}
|
||||
const { context, resModel, views } = params;
|
||||
const key = JSON.stringify([resModel, views, context, loadViewsOptions]);
|
||||
let filteredContext = Object.fromEntries(Object.entries(context || {}).filter((k,v) => !String(k).startsWith("default_")));
|
||||
const key = JSON.stringify([resModel, views, filteredContext, loadViewsOptions]);
|
||||
if (!cache[key]) {
|
||||
cache[key] = orm
|
||||
.call(resModel, "get_views", [], { context, views, options: loadViewsOptions })
|
||||
|
||||
@@ -53,6 +53,7 @@ QUnit.module("View service", (hooks) => {
|
||||
{
|
||||
resModel: "take.five",
|
||||
views: [[99, "list"]],
|
||||
context: {default_field_value: 1},
|
||||
},
|
||||
{}
|
||||
);
|
||||
@@ -60,6 +61,7 @@ QUnit.module("View service", (hooks) => {
|
||||
{
|
||||
resModel: "take.five",
|
||||
views: [[99, "list"]],
|
||||
context: {default_field_value: 2},
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user