mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-16 12:12:57 -06:00
parent
1e789172c4
commit
ea811f8d59
78
help_popup_document_page/README.rst
Normal file
78
help_popup_document_page/README.rst
Normal file
@ -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
|
||||||
|
<https://github.com/OCA/knowledge/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 <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
------------
|
||||||
|
|
||||||
|
* Holger Brunn <hbrunn@therp.nl>
|
||||||
|
|
||||||
|
Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list <mailto:community@mail.odoo.com>`_ or the `appropriate specialized mailinglist <https://odoo-community.org/groups>`_ 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.
|
5
help_popup_document_page/__init__.py
Normal file
5
help_popup_document_page/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2017 Therp BV <http://therp.nl>
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
from . import models
|
||||||
|
from .hooks import post_init_hook
|
24
help_popup_document_page/__openerp__.py
Normal file
24
help_popup_document_page/__openerp__.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2017 Therp BV <http://therp.nl>
|
||||||
|
# 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",
|
||||||
|
}
|
9
help_popup_document_page/data/document_page.xml
Normal file
9
help_popup_document_page/data/document_page.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data noupdate="1">
|
||||||
|
<record id="page_category" model="document.page">
|
||||||
|
<field name="name">Documentation</field>
|
||||||
|
<field name="type">category</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</openerp>
|
23
help_popup_document_page/demo/document_page.xml
Normal file
23
help_popup_document_page/demo/document_page.xml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
<record id="demo_help0" model="document.page">
|
||||||
|
<field name="parent_id" ref="help_popup_document_page.page_category" />
|
||||||
|
<field name="name">Help for groups</field>
|
||||||
|
<field name="content">This is the help for groups</field>
|
||||||
|
<field name="help_popup_window_action_ids" eval="[(4, ref('base.action_res_users'))]" />
|
||||||
|
</record>
|
||||||
|
<record id="demo_help1" model="document.page">
|
||||||
|
<field name="parent_id" ref="help_popup_document_page.page_category" />
|
||||||
|
<field name="name">Help for groups - additional</field>
|
||||||
|
<field name="content">This should be concatenated</field>
|
||||||
|
<field name="help_popup_window_action_ids" eval="[(4, ref('base.action_res_users'))]" />
|
||||||
|
</record>
|
||||||
|
<record id="demo_help_advanced" model="document.page">
|
||||||
|
<field name="parent_id" ref="help_popup_document_page.page_category" />
|
||||||
|
<field name="name">Help for groups - advanced</field>
|
||||||
|
<field name="content">This is the advanced help for groups</field>
|
||||||
|
<field name="help_popup_window_advanced_action_ids" eval="[(4, ref('base.action_res_users'))]" />
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</openerp>
|
31
help_popup_document_page/hooks.py
Normal file
31
help_popup_document_page/hooks.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2017 Therp BV <http://therp.nl>
|
||||||
|
# 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
|
||||||
|
})
|
5
help_popup_document_page/models/__init__.py
Normal file
5
help_popup_document_page/models/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2017 Therp BV <http://therp.nl>
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
from . import document_page
|
||||||
|
from . import ir_actions_act_window
|
20
help_popup_document_page/models/document_page.py
Normal file
20
help_popup_document_page/models/document_page.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2017 Therp BV <http://therp.nl>
|
||||||
|
# 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'
|
||||||
|
)
|
43
help_popup_document_page/models/ir_actions_act_window.py
Normal file
43
help_popup_document_page/models/ir_actions_act_window.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2017 Therp BV <http://therp.nl>
|
||||||
|
# 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
|
15
help_popup_document_page/security/res_groups.xml
Normal file
15
help_popup_document_page/security/res_groups.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
<record id="group_documentation_writer" model="res.groups">
|
||||||
|
<field name="name">Documentation writer</field>
|
||||||
|
<field name="implied_ids" eval="[(4, ref('base.group_document_user'))]" />
|
||||||
|
<field name="category_id" ref="base.module_category_knowledge_management"/>
|
||||||
|
</record>
|
||||||
|
<record id="group_advanced_documentation_writer" model="res.groups">
|
||||||
|
<field name="name">Advanced documentation writer</field>
|
||||||
|
<field name="implied_ids" eval="[(4, ref('help_popup_document_page.group_documentation_writer'))]" />
|
||||||
|
<field name="category_id" ref="base.module_category_knowledge_management"/>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</openerp>
|
BIN
help_popup_document_page/static/description/icon.png
Normal file
BIN
help_popup_document_page/static/description/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
4
help_popup_document_page/tests/__init__.py
Normal file
4
help_popup_document_page/tests/__init__.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2017 Therp BV <http://therp.nl>
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
from . import test_help_popup_document_page
|
@ -0,0 +1,17 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2017 Therp BV <http://therp.nl>
|
||||||
|
# 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,
|
||||||
|
'<p>This is the help for groups\nThis should be concatenated\n</p>'
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
action.advanced_help,
|
||||||
|
'<p>This is the advanced help for groups</p>'
|
||||||
|
)
|
15
help_popup_document_page/views/document_page.xml
Normal file
15
help_popup_document_page/views/document_page.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
<record id="document_page_form" model="ir.ui.view">
|
||||||
|
<field name="model">document.page</field>
|
||||||
|
<field name="inherit_id" ref="document_page.view_wiki_form" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="parent_id" position="after">
|
||||||
|
<field name="help_popup_window_action_ids" widget="many2many_tags" attrs="{'invisible': [('parent_id', '!=', %(help_popup_document_page.page_category)s)]}" groups="help_popup_document_page.group_documentation_writer" />
|
||||||
|
<field name="help_popup_window_advanced_action_ids" widget="many2many_tags" attrs="{'invisible': [('parent_id', '!=', %(help_popup_document_page.page_category)s)]}" groups="help_popup_document_page.group_advanced_documentation_writer" />
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</openerp>
|
1
oca_dependencies.txt
Normal file
1
oca_dependencies.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
web
|
Loading…
Reference in New Issue
Block a user