Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][FW] document_page: Port from 14.0 #510

Open
wants to merge 4 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .oca/oca-port/blacklist/document_page.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"pull_requests": {
"345": "false-positive",
"351": "false-positive",
"371": "false-positive",
"414": "false-positive",
"426": "false-positive",
"477": "false-positive",
"339": "false-positive"
}
}
40 changes: 20 additions & 20 deletions document_page/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ Usage

To use this module, you need to:

- Go to Knowledge menu
- Click on Categories to create the document's category you need with
the template
- Click on Pages to create pages and select the previous category to
use the template
- Go to Knowledge menu
- Click on Categories to create the document's category you need with
the template
- Click on Pages to create pages and select the previous category to use
the template

Bug Tracker
===========
Expand All @@ -78,32 +78,32 @@ Authors
Contributors
------------

- Gervais Naoussi <gervaisnaoussi@gmail.com>
- Maxime Chambreuil <mchambreuil@ursainfosystems.com>
- Iván Todorovich <ivan.todorovich@gmail.com>
- Jose Maria Alzaga <jose.alzaga@aselcis.com>
- Lois Rilo <lois.rilo@forgeflow.com>
- Simone Orsi <simone.orsi@camptocamp.com>
- `Tecnativa <https://www.tecnativa.com>`__:
- Gervais Naoussi <gervaisnaoussi@gmail.com>
- Maxime Chambreuil <mchambreuil@ursainfosystems.com>
- Iván Todorovich <ivan.todorovich@gmail.com>
- Jose Maria Alzaga <jose.alzaga@aselcis.com>
- Lois Rilo <lois.rilo@forgeflow.com>
- Simone Orsi <simone.orsi@camptocamp.com>
- `Tecnativa <https://www.tecnativa.com>`__:

- Ernesto Tejeda
- Víctor Martínez
- Ernesto Tejeda
- Víctor Martínez

Trobz

- Dung Tran <dungtd@trobz.com>
- `Sygel <https://www.sygel.es>`__:
- Dung Tran <dungtd@trobz.com>
- `Sygel <https://www.sygel.es>`__:

- Ángel García de la Chica Herrera
- Ángel García de la Chica Herrera

Other credits
-------------

The development of this module has been financially supported by:

- Odoo SA <http://www.odoo.com>
- Savoir-faire Linux <http://www.savoirfairelinux.com>
- Camptocamp
- Odoo SA <http://www.odoo.com>
- Savoir-faire Linux <http://www.savoirfairelinux.com>
- Camptocamp

Maintainers
-----------
Expand Down
2 changes: 2 additions & 0 deletions document_page/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"assets": {
"web.assets_backend": [
"document_page/static/src/scss/document_page.scss",
"document_page/static/src/js/document_page_kanban_controller.esm.js",
"document_page/static/src/js/document_page_kanban_view.esm.js",
],
},
}
3 changes: 3 additions & 0 deletions document_page/models/document_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class DocumentPage(models.Model):
compute="_compute_backend_url",
)

image = fields.Binary(attachment=True)
color = fields.Integer(string="Color Index")

@api.depends("menu_id", "parent_id.menu_id")
def _compute_backend_url(self):
tmpl = "/web#id={}&model=document.page&view_type=form"
Expand Down
15 changes: 9 additions & 6 deletions document_page/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -402,8 +403,8 @@ <h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
<li>Go to Knowledge menu</li>
<li>Click on Categories to create the document’s category you need with
the template</li>
<li>Click on Pages to create pages and select the previous category to
use the template</li>
<li>Click on Pages to create pages and select the previous category to use
the template</li>
</ul>
</div>
<div class="section" id="bug-tracker">
Expand Down Expand Up @@ -458,7 +459,9 @@ <h2><a class="toc-backref" href="#toc-entry-8">Other credits</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down
19 changes: 19 additions & 0 deletions document_page/static/src/js/document_page_kanban_controller.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** @odoo-module **/
import {KanbanController} from "@web/views/kanban/kanban_controller";

export class DocumentPageKanbanController extends KanbanController {
/**
* @param {Object} record
*/
async openRecord(record) {
const element = document.querySelector(
`.o_kanban_record[data-id="${record.id}"] .o_document_page_kanban_boxes a`
);

if (this.props.resModel === "document.page" && element) {
element.click();
} else {
await super.openRecord(record);
}
}
}
11 changes: 11 additions & 0 deletions document_page/static/src/js/document_page_kanban_view.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @odoo-module **/
import {registry} from "@web/core/registry";
import {kanbanView} from "@web/views/kanban/kanban_view";
import {DocumentPageKanbanController} from "./document_page_kanban_controller.esm";

export const documentPageKanbanView = {
...kanbanView,
Controller: DocumentPageKanbanController,
};

registry.category("views").add("document_page_kanban_view", documentPageKanbanView);
19 changes: 16 additions & 3 deletions document_page/views/document_page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,17 @@
/>
<field name="active" invisible="1" />
<field name="type" invisible="1" />
<h1>
<field name="name" placeholder="Name" />
</h1>
<field
name="image"
widget="image"
class="oe_avatar"
style="z-index:1"
/>
<div class="oe_title">
<h1>
<field name="name" placeholder="Name" />
</h1>
</div>
<field
name="content"
widget="html"
Expand Down Expand Up @@ -138,6 +146,11 @@
<field name="model">document.page</field>
<field name="arch" type="xml">
<search string="Document Page">
<field
name="draft_summary"
string="Summary"
filter_domain="[('draft_summary','ilike',self)]"
/>
<field
name="name"
string="Content"
Expand Down
164 changes: 161 additions & 3 deletions document_page/views/document_page_category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
<form string="Category">
<sheet>
<field name="type" invisible="1" />
<h1>
<field name="name" placeholder="Name" />
</h1>
<field name="image" widget="image" class="oe_avatar" />
<div class="oe_title">
<h1>
<field name="name" placeholder="Name" />
</h1>
</div>
<group>
<group>
<field
Expand Down Expand Up @@ -55,6 +58,153 @@
</form>
</field>
</record>
<record id="view_browse_top_document_filter" model="ir.ui.view">
<field name="name">document.page.category.search</field>
<field name="model">document.page</field>
<field name="inherit_id" ref="view_wiki_filter" />
<field name="arch" type="xml">
<field name="content_uid" position="after">
<separator />
<filter
string="Top Level Ressources"
name="no_parent_id"
domain="[('parent_id', '=', False)]"
/>
</field>
</field>
</record>
<record id="action_browse_top_content" model="ir.actions.act_window">
<field name="name">Browse Wiki Content</field>
<field name="res_model">document.page</field>
<field name="domain">[]</field>
<field
name="context"
>{'default_type': 'content', 'search_default_no_parent_id':1, }</field>
<field name="view_mode">kanban,tree,form</field>
<field name="search_view_id" ref="view_browse_top_document_filter" />
</record>
<record id="action_browse_all_content" model="ir.actions.act_window">
<field name="name">Browse Wiki Content</field>
<field name="res_model">document.page</field>
<field name="domain">[]</field>
<field
name="context"
>{'default_type': 'content', 'search_default_parent_id': [active_id] }</field>
<field name="view_mode">kanban,tree,form</field>
<field name="search_view_id" ref="view_wiki_filter" />
</record>
<record id="view_browse_content_kanban" model="ir.ui.view">
<field name="name">document.page.browse.kanban</field>
<field name="model">document.page</field>
<field name="arch" type="xml">
<kanban js_class="document_page_kanban_view">
<field name="id" />
<field name="name" />
<field name="display_name" />
<field name="create_uid" />
<field name="write_date" />
<field name="parent_id" />
<field name="content_uid" />
<field name="image" />
<field name="type" />
<field name="color" />
<templates>
<t t-name="kanban-box">
<div
t-att-class="'oe_kanban_global_area' + ' oe_kanban_color_'+ (kanban_getcolor(record.color.raw_value)) + ' oe_kanban_global_click' "
>
<div class="o_kanban_image">
<div class="o_kanban_image_wrapper">
<t t-if="record.type.raw_value == 'category'">
<img
class="o_kanban_image"
t-if="record.image.raw_value"
t-att-src="kanban_image('document.page', 'image', record.id.raw_value)"
t-att-alt="record.display_name"
/>
<span
style="font-size: 64px; color: lightslategray"
>
<i
t-if="!record.image.raw_value"
class="o_kanban_image fa fa-folder-open"
/>
</span>
</t>
<t t-if="record.type.raw_value == 'content'">
<span style="font-size: 64px; color: lightgray">
<i class="o_kanban_image fa fa-file" />
</span>
</t>
</div>
</div>
<div class="o_kanban_details">
<div class="o_kanban_details_wrapper">
<div class="o_kanban_record_top">
<div
class="o_kanban_record_title o_text_overflow"
>
<strong>
<field name="name" />
</strong>
<br />
<small t-if="record.parent_id.raw_value">
<img
t-att-src="kanban_image('document.page', 'image', record.parent_id.raw_value)"
t-att-alt="record.parent_id.display_name"
style="margin-right:5px; width:24px; height:24px;"
/>
<field name="parent_id" />
</small>
</div>
</div>

<div class="o_kanban_record_body">
<div class="o_kanban_tags_section">
</div>
</div>
<div
class="o_kanban_record_bottom"
t-if="record.type.raw_value == 'content'"
>
<div class="oe_kanban_bottom_left">
<field name="write_date" widget="date" />
</div>
<div class="oe_kanban_bottom_right">
<img
t-att-src="kanban_image('res.users', 'image_small', record.content_uid.raw_value)"
t-att-title="record.content_uid.value"
t-att-alt="record.content_uid.value"
width="24"
height="24"
class="oe_kanban_avatar"
/>
</div>
</div>
</div>
</div>

<div
t-if="record.type.raw_value == 'category'"
class="o_document_page_kanban_boxes"
>
<a
class="o_document_page_kanban_box"
name="%(action_browse_all_content)d"
type="action"
>
</a>
</div>
</div>
</t>

<t t-name="kanban-menu">
<ul class="oe_kanban_colorpicker" data-field="color" />
</t>
</templates>
</kanban>
</field>
</record>
<record id="view_category_tree" model="ir.ui.view">
<field name="name">document.page.category.tree</field>
<field name="model">document.page</field>
Expand Down Expand Up @@ -132,4 +282,12 @@
action="action_category"
sequence="20"
/>
<menuitem
id="menu_browse_content"
parent="document_knowledge.menu_document_root"
name="Browse Wiki Content"
action="action_browse_top_content"
sequence="5"
/>

</odoo>
Loading