diff --git a/help_popup/README.rst b/help_popup/README.rst
index 1cc6c224..516d9bd7 100644
--- a/help_popup/README.rst
+++ b/help_popup/README.rst
@@ -5,25 +5,21 @@
Help Popup
===========
-This module adds an html help popup on each model action.
-Two help fields are added to actions: enduser_help (html widget)
-and advanced_help.
-
-
-Installation
-============
-
-It was tested on Odoo 8.0 branch.
+This module adds an html help popup on each model action.
+It brings to end users inline documentation.
+Some parts of the documentation can be modified by anyone (with proper rights).
Configuration
=============
-Go to the action of your choice to add some help content
-or put data in some modules.
+* Go to any view and click on the `?` near the title view.
+* Edit the html field to add content
+
-To display the button which open the popup, enduser_help or advanced_help field
-should be set to any value.
+* You can provide documentation with this module by appending data
+ in the field advanced_help (relative to action) or advanced_help_model
+ if your help must be associated to model instead of action
Usage
diff --git a/help_popup/__openerp__.py b/help_popup/__openerp__.py
index 9586533d..52f20da8 100644
--- a/help_popup/__openerp__.py
+++ b/help_popup/__openerp__.py
@@ -1,27 +1,10 @@
# coding: utf-8
-##############################################################################
-#
-# Odoo, Open Source Management Solution
-# Copyright (C) 2015-TODAY Akretion ().
-#
-# 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 .
-#
-##############################################################################
+# © 2015 David BEAL @ Akretion
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Help Popup',
- 'version': '8.0.0.5.0',
+ 'version': '8.0.2.0.0',
'author': 'Akretion, Odoo Community Association (OCA)',
'depends': [
'web',
@@ -32,6 +15,7 @@
'views/action_view.xml',
'report/report.xml',
'report/help.xml',
+ 'report/all.xml',
],
'demo': [
'demo/help.xml',
diff --git a/help_popup/demo/help.xml b/help_popup/demo/help.xml
index 777ec69a..44d5ab67 100644
--- a/help_popup/demo/help.xml
+++ b/help_popup/demo/help.xml
@@ -1,7 +1,7 @@
-
+
+You can write any html tag. Here is an image with img tag
+
+
+
+
]]>
-
-
Hi developers,
+Hi Odoo community,
@@ -35,18 +38,42 @@ Don't hesitate to customized me with your own words and syntax
I'm the field 'advanced_help' in the customer action also displayed in Qweb report.
-Akretion wrote these words to explain my main purpose:
+I wrote these words to explain the main purpose:
-Allows to developers to write documentation on their work.
+Odoo community companies can insert their documenation here with data in their modules.
+Then, any end users can see this documentation in one click.
+
+End users can also display and print documentation about an entire menu.
-You can write any html tag. Here is an image with img tag
-
+ ]]>
+
+
+
+
+
+A supplier can have several specialities.
+
+Use these multicategories to classify your partners
+
+ ]]>
+
+
+
+
+
+Who does not want to rob a bank?
+
+;-)
]]>
diff --git a/help_popup/model.py b/help_popup/model.py
index 9c0a3b70..227915a4 100644
--- a/help_popup/model.py
+++ b/help_popup/model.py
@@ -1,35 +1,127 @@
# coding: utf-8
-##############################################################################
-#
-# Odoo, Open Source Management Solution
-# Copyright (C) 2015-TODAY Akretion ().
-#
-# 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 .
-#
-##############################################################################
-
-from openerp import models, fields
+# © 2015 David BEAL @ Akretion
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+from openerp import _, api, models, fields
-class IrActionsActwindow(models.Model):
- _inherit = 'ir.actions.act_window'
+
+class ErpHelp(models.AbstractModel):
+ _name = 'erp.help'
enduser_help = fields.Html(
string="End User Help",
help="Use this field to add custom content for documentation purpose\n"
"mainly by power users ")
advanced_help = fields.Text(
- string="Advanced Help",
+ string="Advanced Help", groups='base.group_no_one',
help="Use this field to add custom content for documentation purpose\n"
- "mainly by developers")
+ "mainly by developers or consultants")
+
+
+class IrModel(models.Model):
+ _inherit = ['ir.model', 'erp.help']
+ _name = 'ir.model'
+
+
+class IrActionsActwindow(models.Model):
+ _inherit = ['ir.actions.act_window', 'erp.help']
+ _name = 'ir.actions.act_window'
+ _rpt_menu = False
+
+ enduser_help_model = fields.Html(
+ string='Enduser Help from Model', store="True",
+ compute='_compute_model_help', inverse='_inverse_model_help',
+ help="")
+ advanced_help_model = fields.Text(
+ string='Advanced Help from model', store="True",
+ compute='_compute_model_help', inverse='_inverse_model_help',
+ help="")
+ action_help = fields.Boolean(string="Display Action Help")
+ help_has_content = fields.Boolean(
+ string="Content in help", compute='_compute_contains_help',
+ help="One of the help has content")
+
+ @api.one
+ @api.depends('enduser_help', 'advanced_help',
+ 'enduser_help_model', 'advanced_help_model')
+ def _compute_contains_help(self):
+ if (self.enduser_help or self.enduser_help_model or
+ self.advanced_help or self.advanced_help_model):
+ self.help_has_content = True
+ else:
+ self.help_has_content = False
+
+ @api.multi
+ def _compute_model_help(self):
+ for rec in self:
+ model = rec.env['ir.model'].search([('model', '=', rec.res_model)])
+ rec.enduser_help_model = model.enduser_help
+ rec.advanced_help_model = model.advanced_help
+
+ def _inverse_model_help(self):
+ for rec in self:
+ model = rec.env['ir.model'].search([('model', '=', rec.res_model)])
+ model.enduser_help = rec.enduser_help_model
+ model.advanced_help = rec.advanced_help_model
+
+ @api.multi
+ def open_help_popup(self):
+ """ Open in a new tab instead of in popup"""
+ self.ensure_one()
+ return {
+ 'name': _('Open help for this action'),
+ 'type': 'ir.actions.act_url',
+ 'url': 'report/html/help_popup.tpl_help/%s' % self.id,
+ 'target': 'new',
+ }
+
+ @api.model
+ def get_help_actions(self):
+ """ called by the template"""
+ self._rpt_menu = self.get_main_menu()
+ menu_names = self.get_menu_names(self._rpt_menu)
+ actions = self.search([
+ ('id', 'in', menu_names.keys()),
+ '|', '|', '|',
+ ('enduser_help', '!=', False),
+ ('enduser_help_model', '!=', False),
+ ('advanced_help', '!=', False),
+ ('advanced_help_model', '!=', False),
+ ])
+ return actions
+
+ @api.model
+ def get_main_menu(self):
+ self._rpt_menu = False
+ ir_vals = self.env['ir.values'].search([
+ ('key2', '=', 'tree_but_open'),
+ ('key', '=', 'action'),
+ ('res_id', '>', 0),
+ ('value', '=', 'ir.actions.act_window,%s' % self.id),
+ ])
+ if ir_vals:
+ # we only keep the first menu beacause we have no info on menu_id
+ self._rpt_menu = self.env['ir.ui.menu'].browse(ir_vals[0].res_id)
+ while self._rpt_menu.parent_id:
+ self._rpt_menu = self._rpt_menu.parent_id
+ return self._rpt_menu
+
+ @api.model
+ def get_menu_names(self, main_menu):
+ """ @return dict {action_id: 'menu name'} """
+ menus = self.env['ir.ui.menu'].search(
+ [('id', 'child_of', main_menu.id)])
+ ir_vals = self.env['ir.values'].search([
+ ('key2', '=', 'tree_but_open'),
+ ('key', '=', 'action'),
+ ('res_id', 'in', menus.ids),
+ ('value', 'like', 'ir.actions.act_window,%'),
+ ])
+ map_menu = {x.id: x.name for x in menus}
+ return {int(x.value[22:]): map_menu[x.res_id] for x in ir_vals}
+
+ def _anchorize(self, string):
+ """ called by template """
+ for char in ["'", '"', ' ']:
+ string = string.replace(char, '-')
+ return string
diff --git a/help_popup/report/all.xml b/help_popup/report/all.xml
new file mode 100644
index 00000000..db7efbea
--- /dev/null
+++ b/help_popup/report/all.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/help_popup/report/help.xml b/help_popup/report/help.xml
index 678aa45d..e2aaa05f 100644
--- a/help_popup/report/help.xml
+++ b/help_popup/report/help.xml
@@ -13,18 +13,34 @@
-
-
-
-
-
Help from developer
-
-
-
-
-
Help from Odoo
-
-
+
+
+
+
+
+
+
+
Use Ctrl + P to print this document
diff --git a/help_popup/report/report.xml b/help_popup/report/report.xml
index b0ecadc6..8811c168 100644
--- a/help_popup/report/report.xml
+++ b/help_popup/report/report.xml
@@ -3,11 +3,18 @@
-
+
+
+
+
diff --git a/help_popup/static/src/js/popup_help.js b/help_popup/static/src/js/popup_help.js
index 82b1290b..67e8e45d 100644
--- a/help_popup/static/src/js/popup_help.js
+++ b/help_popup/static/src/js/popup_help.js
@@ -6,24 +6,40 @@ openerp.help_popup = function(instance, local) {
do_create_view: function(view_type) {
var self = this;
var res = self._super(view_type);
+ var params = 'height=650, width=900, location=no, ';
+ params += 'resizable=yes, menubar=yes, scrollbars=yes';
+ self.$el.find('span.update_help').each(function () {
+ var $elem = $(this);
+ if ($elem.data('click-init')) {
+ return true;
+ }
+ $elem.data('click-init', true);
+ console.log('me ' + self)
+ if (self.action.id == undefined || self.action.help_has_content == true) {
+ self.$el.find('span.update_help').hide()
+ }
+ $elem.on('click', function(e) {
+ path = self.action.id;
+ my_window = window.open('/web#id='+ path +'&view_type=form&model=ir.actions.act_window&action=help_popup.action_help_popup_form', 'Help', params);
+ // allows to back to the window if opened previoulsy
+ setTimeout('my_window.focus()', 1);
+ });
+ return true;
+ });
self.$el.find('span.view_help').each(function () {
var $elem = $(this);
if ($elem.data('click-init')) {
return true;
}
$elem.data('click-init', true);
- if (self.action.id == undefined || (self.action.advanced_help == '' && self.action.enduser_help == '')) {
+ if (self.action.id == undefined || self.action.help_has_content == false) {
self.$el.find('span.view_help').hide()
}
$elem.on('click', function(e) {
- var params = 'height=650, width=800, location=no, ';
- params += 'resizable=yes, menubar=yes';
path = self.action.id;
my_window = window.open('/report/html/help_popup.tpl_help/' + path, 'Help', params);
- // allows to back to the window if opened previoulsy
setTimeout('my_window.focus()', 1);
});
-
return true;
});
diff --git a/help_popup/static/src/xml/popup_help.xml b/help_popup/static/src/xml/popup_help.xml
index 4c7221eb..509aeeea 100644
--- a/help_popup/static/src/xml/popup_help.xml
+++ b/help_popup/static/src/xml/popup_help.xml
@@ -2,7 +2,10 @@
- ?
+
+ ?
+ ?
diff --git a/help_popup/views/action_view.xml b/help_popup/views/action_view.xml
index 5b59b3b9..4b630e77 100644
--- a/help_popup/views/action_view.xml
+++ b/help_popup/views/action_view.xml
@@ -1,18 +1,90 @@
-
+
-
- ir.actions.act_window
-
-
-
-
-
+
+ ir.actions.act_window
+
+
+
+
+
+
-
-
+
-
+
+ ir.actions.act_window
+
+
+
+
+
+
+ ir.actions.act_window
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+