Skip to content

Commit

Permalink
Merge e89a987 into 607388b
Browse files Browse the repository at this point in the history
  • Loading branch information
LoisRForgeFlow committed Mar 1, 2019
2 parents 607388b + e89a987 commit 189613d
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 30 deletions.
1 change: 1 addition & 0 deletions document_page/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Contributors
* Maxime Chambreuil <mchambreuil@ursainfosystems.com>
* Iván Todorovich <ivan.todorovich@gmail.com>
* Jose Maria Alzaga <jose.alzaga@aselcis.com>
* Lois Rilo <lois.rilo@eficent.com>

Funders
-------
Expand Down
4 changes: 2 additions & 2 deletions document_page/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
'name': 'Document Page',
'version': '11.0.2.2.0',
'version': '11.0.2.3.0',
'category': 'Knowledge Management',
'author': 'OpenERP SA, Odoo Community Association (OCA)',
'images': [
Expand All @@ -15,7 +15,7 @@
'images/customer_invoice.jpeg',
'images/page_history.png',
],
'website': 'http://www.openerp.com/',
'website': 'https://github.com/OCA/knowledge',
'license': 'AGPL-3',
'depends': [
'mail',
Expand Down
9 changes: 8 additions & 1 deletion document_page/models/document_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class DocumentPage(models.Model):
menu_id = fields.Many2one(
'ir.ui.menu',
"Menu",
readonly=True
readonly=True,
)

content_date = fields.Datetime(
Expand Down Expand Up @@ -181,3 +181,10 @@ def _onchange_parent_id(self):
if not self.content or self.content == '<p><br></p>':
if self.parent_id and self.parent_id.type == "category":
self.content = self.parent_id.template

@api.multi
def unlink(self):
menus = self.mapped('menu_id')
res = super().unlink()
menus.unlink()
return res
39 changes: 19 additions & 20 deletions document_page/views/document_page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,25 @@
<field name="name" placeholder="Name"/>
</h1>
<group>
<group>
<field name="parent_id" string="Category" context="{'default_type':'category'}"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
<group>
<field name="content_uid"/>
<field name="content_date"/>
<field name="menu_id" readonly="1" attrs="{'invisible': [('menu_id','=',False)]}"/>
</group>
<div>
<field name="content" widget="html" placeholder="e.g. Once upon a time..." required="1" options="{'safe': True}"/>
</div>
</group>
<notebook>
<page name="content" string="Content">
<group string="Revision" class="oe_edit_only">
<field name="draft_name" placeholder="Rev 01" class="oe_edit_only" />
<field name="draft_summary" placeholder="eg: Changed ... for ..." class="oe_edit_only" />
<page name="info" string="Information">
<group>
<group>
<field name="parent_id" string="Category" context="{'default_type':'category'}"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="content_uid"/>
<field name="content_date"/>
<field name="menu_id" readonly="1" attrs="{'invisible': [('menu_id','=',False)]}"/>
</group>
<group string="Revision" class="oe_edit_only">
<field name="draft_name" placeholder="Rev 01" class="oe_edit_only" />
<field name="draft_summary" placeholder="eg: Changed ... for ..." class="oe_edit_only" />
</group>
</group>
<div>
<label for="content" class="oe_edit_only"/>
<field name="content" widget="html" placeholder="e.g. Once upon a time..." required="1" options="{'safe': True}"/>
</div>
</page>
<page name="history" string="History">
<field name="history_ids">
Expand All @@ -95,12 +94,12 @@
<field name="name">document.page.menu.form</field>
<field name="model">document.page</field>
<field name="arch" type="xml">
<form string="Document Page">
<form string="Document Page" create="0">
<field name="type" invisible="1"/>
<h1>
<field name="name" placeholder="Name"/>
</h1>
<field name="content" class="oe_view_only" required="1" options='{"safe": True}'/>
<field name="content" widget="html" class="oe_view_only" required="1" options='{"safe": True}'/>
</form>
</field>
</record>
Expand Down Expand Up @@ -160,7 +159,7 @@

<menuitem id="menu_wiki"
name="Pages"
parent="knowledge.menu_document_section"
parent="knowledge.menu_document_root"
sequence="10"/>


Expand Down
20 changes: 19 additions & 1 deletion document_page/views/document_page_category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@
</field>
</record>

<record id="view_document_category_filter" model="ir.ui.view">
<field name="name">document.page.category.search</field>
<field name="model">document.page</field>
<field name="arch" type="xml">
<search string="Document Category">
<field name="name" string="Content"
filter_domain="['|', ('name','ilike',self), ('template','ilike',self)]"/>
<field name="parent_id"/>
<field name="create_uid"/>
<field name="content_uid"/>
<group expand="0" string="Group By...">
<filter string="Category" context="{'group_by':'parent_id'}"/>
<filter string="Author" context="{'group_by':'create_uid'}"/>
<filter string="Last Contributor" context="{'group_by':'content_uid'}"/>
</group>
</search>
</field>
</record>

<!-- Category Action -->
<record id="action_category" model="ir.actions.act_window">
Expand All @@ -61,7 +79,7 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_category_tree"/>
<field name="search_view_id" ref="view_wiki_filter"/>
<field name="search_view_id" ref="view_document_category_filter"/>
</record>

<record id="action_category_view_tree" model="ir.actions.act_window.view">
Expand Down
4 changes: 3 additions & 1 deletion document_page/wizard/document_page_create_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def document_page_menu_create(self):
'res_model': 'document.page',
'view_id': view_id,
'type': 'ir.actions.act_window',
'target': 'inline',
'target': 'current',
}
value['domain'] = "[('parent_id','=',%d)]" % (page.id)
value['res_id'] = page.id
Expand All @@ -66,6 +66,8 @@ def document_page_menu_create(self):
'parent_id': data.menu_parent_id.id,
'action': 'ir.actions.act_window,' + str(action_id.id),
})
if page.menu_id:
page.menu_id.unlink()
page.write({'menu_id': menu_id.id})
return {
'type': 'ir.actions.client',
Expand Down
9 changes: 4 additions & 5 deletions document_page/wizard/document_page_create_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
</record>


<!-- Create Menu Action -->
<record id="action_wiki_create_menu"
model="ir.actions.act_window">
<!-- Create Server Action -->
<record id="action_wiki_create_menu" model="ir.actions.act_window">
<field name="name">Create Menu</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">document.page.create.menu</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id"
ref="document_page.model_document_page"/>
</record>

</odoo>

0 comments on commit 189613d

Please sign in to comment.