[FIX] web_editor: clear m2X cache
This commit clears the cache of we-many2X widgets. Since [the merge of the backend into the frontend], the page is not refreshed when the user goes to modify data in his backend. This means that if the data has been changed between two editions of a page and the many2X widget has already made the RPC call, it will not do it again and will still have the old data. For example with website installed: - Edit a page of your website - Add the add to cart button - Search for "ERP" product - The product does not exist so save the page - Create and publish a new product called "ERP" - Edit the page again - Search for the product "ERP" => It is not present because the query is in the cache which has not been cleared. If you refresh the page, the product will be found. This commit fixes this problem by clearing the cache after an edit. Note that a similar implementation of caching clearing has been done here: https://github.com/odoo/odoo/commit/3efb726575679f62f9ee2894193323bfe45d7938 [the merge of the backend into the frontend]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b task-3078137 closes odoo/odoo#124908 X-original-commit: ff0cfca420a434e6024654749ea316bbfc5e0772 Signed-off-by: Romain Derie (rde) <rde@odoo.com> Signed-off-by: Dieleman Guillaume (gdi) <gdi@odoo.com>
This commit is contained in:
@@ -2535,7 +2535,10 @@ const SelectPagerUserValueWidget = SelectUserValueWidget.extend({
|
||||
}
|
||||
});
|
||||
|
||||
const m2oRpcCache = {};
|
||||
let m2oRpcCache = {};
|
||||
const clearM2oRpcCache = () => {
|
||||
m2oRpcCache = {};
|
||||
};
|
||||
const Many2oneUserValueWidget = SelectUserValueWidget.extend({
|
||||
className: (SelectUserValueWidget.prototype.className || '') + ' o_we_many2one',
|
||||
events: Object.assign({}, SelectUserValueWidget.prototype.events, {
|
||||
@@ -8206,4 +8209,6 @@ export default {
|
||||
// Other names for convenience
|
||||
Class: SnippetOptionWidget,
|
||||
registry: registry,
|
||||
|
||||
clearM2oRpcCache,
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@ import { device } from "web.config";
|
||||
import { localization } from "@web/core/l10n/localization";
|
||||
import * as OdooEditorLib from "@web_editor/js/editor/odoo-editor/src/OdooEditor";
|
||||
import snippetsEditor from "web_editor.snippet.editor";
|
||||
import snippetsOptions from "web_editor.snippets.options";
|
||||
import Toolbar from "web_editor.toolbar";
|
||||
import weWidgets from "wysiwyg.widgets";
|
||||
import Link from "wysiwyg.widgets.Link";
|
||||
@@ -746,6 +747,7 @@ const Wysiwyg = Widget.extend({
|
||||
for (const timeout of this.tooltipTimeouts) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
snippetsOptions.clearM2oRpcCache();
|
||||
this._super();
|
||||
},
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user