mirror of https://github.com/OCA/web.git
[ADD] help_contextual_popup
parent
63e82b0b83
commit
681700adea
|
@ -0,0 +1,35 @@
|
||||||
|
Add contextual help popup
|
||||||
|
=========================
|
||||||
|
|
||||||
|
This module add a contextual html help popup on each model action.
|
||||||
|
You also may use dedicated field custom_help on actions to add specific help
|
||||||
|
|
||||||
|
Installation
|
||||||
|
============
|
||||||
|
|
||||||
|
It was tested on Odoo 8.0 branch.
|
||||||
|
|
||||||
|
Credits
|
||||||
|
=======
|
||||||
|
|
||||||
|
Akretion
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
------------
|
||||||
|
|
||||||
|
* Sylvain Calador <sylvain.calador@akretion.com>
|
||||||
|
* David Beal <david.beal@akretion.com>
|
||||||
|
|
||||||
|
Maintainer
|
||||||
|
----------
|
||||||
|
|
||||||
|
.. image:: http://odoo-community.org/logo.png
|
||||||
|
:alt: Odoo Community Association
|
||||||
|
:target: http://odoo-community.org
|
||||||
|
|
||||||
|
This module is maintained by the OCA.
|
||||||
|
|
||||||
|
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
|
||||||
|
|
||||||
|
To contribute to this module, please visit http://odoo-community.org.
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
from . import model
|
|
@ -0,0 +1,40 @@
|
||||||
|
# coding: utf-8
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Odoo, Open Source Management Solution
|
||||||
|
# Copyright (C) 2015-TODAY Akretion (<http://www.akretion.com>).
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': 'Help Contextual Popup',
|
||||||
|
'version': '0.1',
|
||||||
|
'author': 'Akretion, Odoo Community Association (OCA)',
|
||||||
|
'depends': [
|
||||||
|
'web',
|
||||||
|
],
|
||||||
|
'demo': [],
|
||||||
|
'website': 'https://www.akretion.com',
|
||||||
|
'data': [
|
||||||
|
'views/popup_help_view.xml',
|
||||||
|
'views/action_view.xml',
|
||||||
|
],
|
||||||
|
'qweb': [
|
||||||
|
'static/src/xml/popup_help.xml',
|
||||||
|
],
|
||||||
|
'installable': True,
|
||||||
|
'auto_install': False,
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
# coding: utf-8
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Odoo, Open Source Management Solution
|
||||||
|
# Copyright (C) 2015-TODAY Akretion (<http://www.akretion.com>).
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
from openerp import models, fields
|
||||||
|
|
||||||
|
|
||||||
|
class IrActionsActwindow(models.Model):
|
||||||
|
_inherit = 'ir.actions.act_window'
|
||||||
|
|
||||||
|
custom_help = fields.Text(
|
||||||
|
string="Custom Help",
|
||||||
|
help="Use this field to add custom content for documentation purpose")
|
||||||
|
|
|
@ -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;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
|
@ -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>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<record id="view_window_action_form" model="ir.ui.view">
|
||||||
|
<field name="model">ir.actions.act_window</field>
|
||||||
|
<field name="inherit_id"
|
||||||
|
ref="base.view_window_action_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="help" position="after">
|
||||||
|
<field name="custom_help"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
<template id="assets_backend" name="custom assets" inherit_id="web.assets_backend">
|
||||||
|
<xpath expr="." position="inside">
|
||||||
|
<script type="text/javascript" src="/help_contextual_popup/static/src/js/popup_help.js"></script>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</data>
|
||||||
|
</openerp>
|
Loading…
Reference in New Issue