diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index b9dfacc6a19..d08118354a2 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -18,6 +18,26 @@ var qweb = core.qweb; const InputUserValueWidget = options.userValueWidgetsRegistry['we-input']; const SelectUserValueWidget = options.userValueWidgetsRegistry['we-select']; +options.UserValueWidget.include({ + loadMethodsData() { + this._super(...arguments); + + // Method names are sorted alphabetically by default. Exception here: + // we make sure, customizeWebsiteVariable is considered after + // customizeWebsiteViews so that the variable is used to show to active + // value when both methods are used at the same time. + // TODO find a better way. + const indexVariable = this._methodsNames.indexOf('customizeWebsiteVariable'); + if (indexVariable >= 0) { + const indexView = this._methodsNames.indexOf('customizeWebsiteViews'); + if (indexView >= 0) { + this._methodsNames[indexVariable] = 'customizeWebsiteViews'; + this._methodsNames[indexView] = 'customizeWebsiteVariable'; + } + } + }, +}); + const UrlPickerUserValueWidget = InputUserValueWidget.extend({ custom_events: _.extend({}, InputUserValueWidget.prototype.custom_events || {}, { 'website_url_chosen': '_onWebsiteURLChosen',