diff --git a/help_popup_document_page/README.rst b/help_popup_document_page/README.rst new file mode 100644 index 00000000..09659897 --- /dev/null +++ b/help_popup_document_page/README.rst @@ -0,0 +1,78 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +======================= +Document pages for help +======================= + +This module knits ``document_page`` and ``help_popup`` together such that you can write your help texts as document pages. The advantage is that you can use your help texts also as (part of) a functional description of your installation, or the other way around. + +Installation +============ + +To install this module, you need to: + +#. install ``help_popup`` from the ``web`` repository + +Configuration +============= + +To configure this module, you need to: + +#. add users to the `Documentation writer` or `Advanced documentation writer` group +#. if you're so inclined, provide a template in the document category `Documentation` (added by this module) + +Usage +===== + +Members of the above mentioned groups will have access to the the fields `Documentation for` and `Advanced documentation for` on a document page *if* the page's category is `Documentation`. In those fields, assign the window action(s) for which the current document page is the (advanced) documentation. + +Given you can add multiple document pages as help for the same action (they will be concatenated), you can share writing documentation between multiple people writing about different aspects. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/118/8.0 + +Known issues / Roadmap +====================== + +* it would be nice to have this refer to actions instead of window actions, but that's more a matter of help_popup + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Holger Brunn + +Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list `_ or the `appropriate specialized mailinglist `_ for help, and the bug tracker linked in `Bug Tracker`_ above for technical issues. + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://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 https://odoo-community.org. diff --git a/help_popup_document_page/__init__.py b/help_popup_document_page/__init__.py new file mode 100644 index 00000000..5b38452f --- /dev/null +++ b/help_popup_document_page/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import models +from .hooks import post_init_hook diff --git a/help_popup_document_page/__openerp__.py b/help_popup_document_page/__openerp__.py new file mode 100644 index 00000000..2cd90330 --- /dev/null +++ b/help_popup_document_page/__openerp__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Document pages for help", + "version": "8.0.1.0.0", + "author": "Therp BV,Odoo Community Association (OCA)", + "license": "AGPL-3", + "category": "Knowledge Management", + "summary": "Use document pages as help popup", + "depends": [ + 'document_page', + 'help_popup', + ], + "demo": [ + "demo/document_page.xml", + ], + "data": [ + "data/document_page.xml", + "security/res_groups.xml", + "views/document_page.xml", + ], + "post_init_hook": "post_init_hook", +} diff --git a/help_popup_document_page/data/document_page.xml b/help_popup_document_page/data/document_page.xml new file mode 100644 index 00000000..ea5c5aab --- /dev/null +++ b/help_popup_document_page/data/document_page.xml @@ -0,0 +1,9 @@ + + + + + Documentation + category + + + diff --git a/help_popup_document_page/demo/document_page.xml b/help_popup_document_page/demo/document_page.xml new file mode 100644 index 00000000..dbb72f91 --- /dev/null +++ b/help_popup_document_page/demo/document_page.xml @@ -0,0 +1,23 @@ + + + + + + Help for groups + This is the help for groups + + + + + Help for groups - additional + This should be concatenated + + + + + Help for groups - advanced + This is the advanced help for groups + + + + diff --git a/help_popup_document_page/hooks.py b/help_popup_document_page/hooks.py new file mode 100644 index 00000000..bb017446 --- /dev/null +++ b/help_popup_document_page/hooks.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openerp import SUPERUSER_ID, api + + +def post_init_hook(cr, pool): + env = api.Environment( + cr, SUPERUSER_ID, pool['res.users'].context_get(cr, SUPERUSER_ID) + ) + for action in env['ir.actions.act_window'].search([ + '|', + ('enduser_help', '!=', False), + ('advanced_help', '!=', False), + ]): + if action.enduser_help and not action.enduser_document_page_ids: + env['document.page'].create({ + 'name': action.name, + 'parent_id': + env.ref('help_popup_document_page.page_category').id, + 'help_popup_window_action_ids': [(4, action.id)], + 'content': action.enduser_help + }) + if action.advanced_help and not action.advanced_document_page_ids: + env['document.page'].create({ + 'name': action.name, + 'parent_id': + env.ref('help_popup_document_page.page_category').id, + 'help_popup_window_advanced_action_ids': [(4, action.id)], + 'content': action.advanced_help + }) diff --git a/help_popup_document_page/models/__init__.py b/help_popup_document_page/models/__init__.py new file mode 100644 index 00000000..2bf30d82 --- /dev/null +++ b/help_popup_document_page/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import document_page +from . import ir_actions_act_window diff --git a/help_popup_document_page/models/document_page.py b/help_popup_document_page/models/document_page.py new file mode 100644 index 00000000..7ba1278b --- /dev/null +++ b/help_popup_document_page/models/document_page.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openerp import fields, models + + +class DocumentPage(models.Model): + _inherit = 'document.page' + + help_popup_window_action_ids = fields.Many2many( + 'ir.actions.act_window', 'help_popup_document_page_rel', + 'document_page_id', 'action_id', + string='Documentation for' + ) + + help_popup_window_advanced_action_ids = fields.Many2many( + 'ir.actions.act_window', 'help_popup_document_page_advanced_rel', + 'document_page_id', 'action_id', + string='Advanced documentation for' + ) diff --git a/help_popup_document_page/models/ir_actions_act_window.py b/help_popup_document_page/models/ir_actions_act_window.py new file mode 100644 index 00000000..4f6c2ee5 --- /dev/null +++ b/help_popup_document_page/models/ir_actions_act_window.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openerp import api, fields, models, tools + + +class IrActionsActWindow(models.Model): + _inherit = 'ir.actions.act_window' + + enduser_help = fields.Html(compute='_compute_enduser_help', store=True) + advanced_help = fields.Html(compute='_compute_advanced_help', store=True) + enduser_document_page_ids = fields.Many2many( + 'document.page', 'help_popup_document_page_rel', + 'action_id', 'document_page_id', + string='Documentation' + ) + advanced_document_page_ids = fields.Many2many( + 'document.page', 'help_popup_document_page_advanced_rel', + 'action_id', 'document_page_id', + string='Advanced documentation' + ) + + @api.multi + @api.depends('enduser_document_page_ids.content') + def _compute_enduser_help(self): + for this in self: + html_string = this.enduser_document_page_ids[:1].content + for extra_content in this.enduser_document_page_ids[1:]: + html_string = tools.append_content_to_html( + html_string, extra_content.content, plaintext=False + ) + this.enduser_help = html_string + + @api.multi + @api.depends('advanced_document_page_ids.content') + def _compute_advanced_help(self): + for this in self: + html_string = this.advanced_document_page_ids[:1].content + for extra_content in this.advanced_document_page_ids[1:]: + html_string = tools.append_content_to_html( + html_string, extra_content.content, plaintext=False + ) + this.advanced_help = html_string diff --git a/help_popup_document_page/security/res_groups.xml b/help_popup_document_page/security/res_groups.xml new file mode 100644 index 00000000..7948f55c --- /dev/null +++ b/help_popup_document_page/security/res_groups.xml @@ -0,0 +1,15 @@ + + + + + Documentation writer + + + + + Advanced documentation writer + + + + + diff --git a/help_popup_document_page/static/description/icon.png b/help_popup_document_page/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/help_popup_document_page/static/description/icon.png differ diff --git a/help_popup_document_page/tests/__init__.py b/help_popup_document_page/tests/__init__.py new file mode 100644 index 00000000..228c0cd1 --- /dev/null +++ b/help_popup_document_page/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import test_help_popup_document_page diff --git a/help_popup_document_page/tests/test_help_popup_document_page.py b/help_popup_document_page/tests/test_help_popup_document_page.py new file mode 100644 index 00000000..fed3a6fe --- /dev/null +++ b/help_popup_document_page/tests/test_help_popup_document_page.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openerp.tests.common import TransactionCase + + +class TestHelpPopupDocumentPage(TransactionCase): + def test_help_popup_document_page(self): + action = self.env.ref('base.action_res_users') + self.assertEqual( + action.enduser_help, + '

This is the help for groups\nThis should be concatenated\n

' + ) + self.assertEqual( + action.advanced_help, + '

This is the advanced help for groups

' + ) diff --git a/help_popup_document_page/views/document_page.xml b/help_popup_document_page/views/document_page.xml new file mode 100644 index 00000000..fdd30327 --- /dev/null +++ b/help_popup_document_page/views/document_page.xml @@ -0,0 +1,15 @@ + + + + + document.page + + + + + + + + + + diff --git a/oca_dependencies.txt b/oca_dependencies.txt new file mode 100644 index 00000000..c0772185 --- /dev/null +++ b/oca_dependencies.txt @@ -0,0 +1 @@ +web