summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorJulien Mougenot <jum@odoo.com>2020-08-04 14:00:26 +0000
committerJulien Mougenot <jum@odoo.com>2020-08-04 14:04:56 +0000
commit3178fb21b4eb28dea5b81310e7c22425d519e698 (patch)
treef6505835c1ab9445b75aab8f388079cbf745ab58 /addons/web/static/src/js
parent71289ea81909abc6d2200f11d1eb5b3a3bc37704 (diff)
[FIX] web: Deep copy state exported by search panel
Having maps in its state, the search panel has to serialise its state before sending it via exportState. Before this commit, this was done on the state object in place, causing issues if the model was restored without an imported state (no re-serialisation hence having a wrong state). Now, the exported object is deep-copied from the original state. Task 2312131 closes odoo/odoo#55393 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/views/search_panel_model_extension.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/addons/web/static/src/js/views/search_panel_model_extension.js b/addons/web/static/src/js/views/search_panel_model_extension.js
index 3aca92029f3..a5103f97447 100644
--- a/addons/web/static/src/js/views/search_panel_model_extension.js
+++ b/addons/web/static/src/js/views/search_panel_model_extension.js
@@ -38,6 +38,16 @@ odoo.define("web/static/src/js/views/search_panel_model_extension.js", function
}
/**
+ * Returns a serialised array of the given map with its values being the
+ * shallow copies of the original values.
+ * @param {Map<any, Object>} map
+ * @return {Array[]}
+ */
+ function serialiseMap(map) {
+ return [...map].map(([key, val]) => [key, Object.assign({}, val)]);
+ }
+
+ /**
* @typedef Section
* @prop {string} color
* @prop {string} description
@@ -118,14 +128,14 @@ odoo.define("web/static/src/js/views/search_panel_model_extension.js", function
* @override
*/
exportState() {
- const state = super.exportState();
- state.sections = [...state.sections];
+ const state = Object.assign({}, super.exportState());
+ state.sections = serialiseMap(state.sections);
for (const [id, section] of state.sections) {
- section.values = [...section.values];
+ section.values = serialiseMap(section.values);
if (section.groups) {
- section.groups = [...section.groups];
+ section.groups = serialiseMap(section.groups);
for (const [id, group] of section.groups) {
- group.values = [...group.values];
+ group.values = serialiseMap(group.values);
}
}
}