Skip to content

Instantly share code, notes, and snippets.

@KangOl
Last active December 12, 2017 11:05
Show Gist options
  • Save KangOl/af96b6495aab82498838c4fc18451701 to your computer and use it in GitHub Desktop.
Save KangOl/af96b6495aab82498838c4fc18451701 to your computer and use it in GitHub Desktop.
Add a reload button on active breadcrumb
// ==UserScript==
// @name odoo-view-reload
// @namespace odoo.com
// @version 0.1
// @updateURL https://gist.github.com/KangOl/af96b6495aab82498838c4fc18451701/raw/odoo-view-reload.user.js
// @description Add a reload button on active breadcrumb
// @author @KangOl
// @match https://*.odoo.com/web
// @match https://*.odoo.com/web?*
// @grant none
// ==/UserScript==
(function() {
'use strict';
if (!odoo) return;
odoo.define('userscript.viewreload', function(require) {
var ControlPanel = require('web.ControlPanel');
var ViewManager = require('web.ViewManager');
ControlPanel.include({
update: function() {
var self = this;
this._super.apply(this, arguments);
var style = {
'margin-left': '0.5em',
};
var $icon = $('<a>').addClass('invisible fa fa-refresh').css(style).on('click', function() {
var multi = self.nodes.$searchview.is(':visible');
var parent = self.getParent();
var viewmanager = parent.inner_widget instanceof ViewManager ? parent.inner_widget : parent.viewmanager;
if (!viewmanager) { return; }
if (multi) {
viewmanager.searchview.do_search();
} else {
viewmanager.active_view.controller.reload();
}
});
var $active = this.nodes.$breadcrumbs.find('.active');
$active.append($icon);
$active.hover(function() { $icon.toggleClass('invisible'); });
}
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment