[ADD] help_contextual_popup

This commit is contained in:
Sylvain CALADOR
2015-06-17 23:25:15 +02:00
committed by David Beal
parent 63e82b0b83
commit 681700adea
8 changed files with 185 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
openerp.help_contextual_popup = function(instance, local) {
var _t = instance.web._t;
instance.web.ViewManager.include({
do_create_view: function(view_type) {
var self = this;
var res = self._super(view_type);
self.$el.find('span.view_help').each(function () {
var $elem = $(this);
if ($elem.data('click-init')) {
return true;
}
$elem.data('click-init', true);
var help_html = '';
if (self.action.help) {
help_html += '<h3>Odoo Help</h3>'
help_html += '<div id="erp_help">' + self.action.help + '</div>';
}
if (self.action.custom_help) {
help_html += '<h3>Specific Help</h3>'
help_html += '<div id="custom_help">' + self.action.custom_help + '</div>'
}
$elem.on('click', function(e) {
new instance.web.Dialog(self, {
size: 'medium',
title: _t("Help: ") + self.action.name,
buttons: [
{text: _t("Ok"), click: function() { this.parents('.modal').modal('hide');}}
]
}, help_html).open(); // self.action.res_model
});
return true;
});
return res;
},
});
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="ViewManagerAction" t-extend="ViewManagerAction">
<t t-jquery="h2.oe_view_title" t-operation="before">
<span class="oe_button view_help">?</span>
</t>
</t>
</templates>