[FIX] web_editor: cache editor name_search/read across multiple m2o
The RPC that the m2o widgets used by snippet options make are cached at the widget level. When two m2o widgets make the same RPC, they are indeed made twice. This commit just move the cache outside of the widget instance and thus makes it so the same RPC made across multiple m2o are cached. Note: this was particularly visible because all main snippets have the "Conditional Visibility" option which uses 3 m2m widgets. At each drop of such main snippet in the page, the option is created and the 3 m2m widgets made their RPC. Then each further drop of snippet made the exact same RPC for no good reason. In the future, the system should be further improved to not require those RPC on initial drop and clicks, especially as the "Conditional Visibility" m2m widgets are hidden by default. This fix focuses on fixing the generic m2m widgets. closes odoo/odoo#102800 X-original-commit: 8e08c896df9ed5a7a0e559f1dbd8812f87908a39 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
@@ -2465,6 +2465,7 @@ const SelectPagerUserValueWidget = SelectUserValueWidget.extend({
|
||||
},
|
||||
});
|
||||
|
||||
const m2oRpcCache = {};
|
||||
const Many2oneUserValueWidget = SelectUserValueWidget.extend({
|
||||
className: (SelectUserValueWidget.prototype.className || '') + ' o_we_many2one',
|
||||
events: Object.assign({}, SelectUserValueWidget.prototype.events, {
|
||||
@@ -2482,7 +2483,7 @@ const Many2oneUserValueWidget = SelectUserValueWidget.extend({
|
||||
init(parent, title, options, $target) {
|
||||
this.afterSearch = [];
|
||||
this.displayNameCache = {};
|
||||
this._rpcCache = {};
|
||||
this._rpcCache = m2oRpcCache;
|
||||
const {dataAttributes} = options;
|
||||
Object.assign(options, {
|
||||
limit: '5',
|
||||
|
||||
Reference in New Issue
Block a user