Skip to content
Merged
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
2 changes: 1 addition & 1 deletion document_page/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

{
'name': 'Document Page',
'version': '9.0.2.0.0',
'version': '9.0.2.1.0',
'category': 'Knowledge Management',
'author': 'OpenERP SA, Odoo Community Association (OCA)',
'images': ['images/category_list.png', 'images/create_category.png',
Expand Down
19 changes: 16 additions & 3 deletions document_page/models/document_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class DocumentPage(models.Model):
default="content"
)

active = fields.Boolean(default=True)

parent_id = fields.Many2one(
'document.page',
'Category',
Expand All @@ -60,7 +62,16 @@ class DocumentPage(models.Model):
)

# no-op computed field
summary = fields.Char(
draft_name = fields.Char(
string='Name',
help='Name for the changes made',
compute=lambda x: x,
inverse=lambda x: x,
)

# no-op computed field
draft_summary = fields.Char(
string='Summary',
help='Describe the changes made',
compute=lambda x: x,
inverse=lambda x: x,
Expand Down Expand Up @@ -156,10 +167,12 @@ def _compute_content(self):
@api.multi
def _inverse_content(self):
for rec in self:
if rec.type == 'content':
if rec.type == 'content' and \
rec.content != rec.history_head.content:
rec._create_history({
'name': rec.draft_name,
'summary': rec.draft_summary,
'content': rec.content,
'summary': rec.summary,
})

@api.multi
Expand Down
6 changes: 3 additions & 3 deletions document_page/models/document_page_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ class DocumentPageHistory(models.Model):
_order = 'id DESC'

page_id = fields.Many2one('document.page', 'Page', ondelete='cascade')
summary = fields.Char('Summary', index=True)
content = fields.Text("Content")
name = fields.Char(index=True)
summary = fields.Char(index=True)
content = fields.Text()
diff = fields.Text(compute='_compute_diff')

@api.multi
@api.depends('content', 'page_id.history_ids')
def _compute_diff(self):
"""Shows a diff between this version and the previous version"""
history = self.env['document.page.history']
Expand Down
18 changes: 14 additions & 4 deletions document_page/views/document_page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<field name="arch" type="xml">
<form string="Document Page">
<sheet>
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" groups="document_page.group_document_manager" class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button" options="{'terminology': 'archive'}"/>
</button>
</div>
<field name="type" invisible="1"/>
<h1><field name="name" placeholder="Name"/></h1>
<group>
Expand All @@ -54,16 +59,21 @@
</group>
<notebook>
<page name="content" string="Content">
<label for="summary" class="oe_edit_only" />
<field name="summary" placeholder="eg: Changed ... for ..." class="oe_edit_only" />
<label for="content" class="oe_edit_only"/>
<field name="content" widget="html" placeholder="e.g. Once upon a time..." required="1" options="{'safe': True}"/>
<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>
<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">
<tree>
<field name="id"/>
<field name="create_date"/>
<field name="name"/>
<field name="summary"/>
<field name="create_uid"/>
</tree>
Expand Down
10 changes: 6 additions & 4 deletions document_page/views/document_page_history.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<tree string="Document History">
<field name="id"/>
<field name="page_id"/>
<field name="name"/>
<field name="summary"/>
<field name="create_uid"/>
<field name="create_date"/>
Expand Down Expand Up @@ -40,18 +41,19 @@
<field name="arch" type="xml">
<form string="Document Page History">
<sheet>
<h1><field name="page_id"/></h1>
<h1><field name="page_id" readonly="1"/></h1>
<group>
<group>
<field name="create_uid" readonly="1"/>
<field name="create_date" readonly="1"/>
</group>
</group>
<group>
<field name="name" placeholder="Rev 01"/>
<field name="summary" placeholder="eg: Changed ... for ..."/>
</group>
<notebook>
<page name="content" string="Content">
<label for="summary"/>
<field name="summary" placeholder="eg: Changed ... for ..."/>
<label for="content"/>
<field name="content" widget="html" placeholder="e.g. Once upon a time..." options="{'safe': True}"/>
</page>
<page name="diff" string="Changes">
Expand Down