[IMP] knowledge: add no content helpers and sample data

PURPOSE:

- Add no content helpers in the favorite and member views, as well as
on the main "article" view: when no article exists, a smiling face
suggests to create one, when no favorite relation exists, a smiling
face suggests to add an article to the favorites and explains how to
do it, and when no member relation exists, the purpose of creating
one is explained.

- Add samples in background when there are no records in the members
and favorite views.

- Set the favorite list views as editable=bottom to allow
modifications from the list view.

- Remove the sequence handle in the favorite list view to prevent
reordering, because it led to strange behaviors since the favorite
articles are ordered by user id.

- Disallow users to create or edit records in the members view, as
creation and edition are normally handled by custom methods, that won't
be triggered when creating or editing from this view.

- Allow users to search for articles based on their content.

- Make the favorite and member views open to admin users in debug mode
only, instead of all internal users in debug mode.

These additions have been made with the aim of improving the user
experience.

Task-2852946

X-original-commit: 1e9fcafa59c421607d781d2fc4b760598ed2e3fb
Part-of: odoo/odoo#93834
This commit is contained in:
Adrien Schoffeniels
2022-06-16 18:32:08 +02:00
parent 9a5d575406
commit 048a1d2f87
4 changed files with 36 additions and 9 deletions
@@ -20,10 +20,9 @@
<field name="name">knowledge.article.favorite.view.tree</field>
<field name="model">knowledge.article.favorite</field>
<field name="arch" type="xml">
<tree string="Favorites">
<field name="sequence" widget="handle"/>
<field name="article_id"/>
<field name="user_id"/>
<tree string="Favorites" sample="1" editable="bottom">
<field name="article_id" options="{'no_open': True}"/>
<field name="user_id" widget="many2one_avatar"/>
</tree>
</field>
</record>
@@ -49,6 +48,14 @@
<field name="name">Favorites</field>
<field name="res_model">knowledge.article.favorite</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
No Favorites yet!
</p>
<p>
Add articles in your list of favorites by clicking on the <i class="fa fa-star-o"/> next to the article name.
</p>
</field>
</record>
</odoo>
@@ -22,11 +22,10 @@
<field name="name">knowledge.article.member.view.tree</field>
<field name="model">knowledge.article.member</field>
<field name="arch" type="xml">
<tree string="Members">
<tree string="Members" sample="1" create="0" edit="0">
<field name="article_id"/>
<field name="partner_id"/>
<field name="partner_id" widget="many2one_avatar"/>
<field name="permission"/>
<field name="article_permission"/>
</tree>
</field>
</record>
@@ -52,6 +51,14 @@
<field name="name">Members</field>
<field name="res_model">knowledge.article.member</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
No Members yet!
</p>
<p>
Adding members allows you to share Articles while granting specific access rights<br />(can write, can read, ...).
</p>
</field>
</record>
</odoo>
@@ -193,6 +193,18 @@
aria-labelledby="o_article_emoji" />
</div>
</div>
<!-- No article helper -->
<field name="category" invisible="1"/>
<div class="o_view_nocontent" attrs="{'invisible': [('id', '!=', False)]}">
<div class="o_nocontent_help">
<p class="o_view_nocontent_smiling_face">
No article yet.
</p>
<p>
<a href="#" role="button" class="btn-create">Create an article</a> to unleash the power of Knowledge !
</p>
</div>
</div>
<!-- Article body -->
<div class="o_knowledge_editor d-flex flex-grow-1">
<field name="body" widget="html" no_label="1" default_focus="1"
@@ -295,6 +307,7 @@
<search>
<field name="name"/>
<field name="root_article_id"/>
<field name="body"/>
<field name="last_edition_uid"/>
<filter name="filter_active" string="Archived"
+2 -2
View File
@@ -31,13 +31,13 @@
name="Members"
action="knowledge.knowledge_article_member_action"
parent="knowledge_menu_configuration"
groups="base.group_no_one"
groups="base.group_system"
sequence="1"/>
<menuitem
id="knowledge_article_favorite_menu"
name="Favorites"
action="knowledge.knowledge_article_favorite_action"
parent="knowledge_menu_configuration"
groups="base.group_no_one"
groups="base.group_system"
sequence="2"/>
</odoo>