mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-17 12:42:56 -06:00
[document_page] FIX creating history when there are no changes made. Add history name field, to name revisions. Modified views to allow setting this field.
This commit is contained in:
parent
e37d525e29
commit
31d95fe243
@ -42,7 +42,16 @@ class DocumentPage(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# no-op computed field
|
# 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',
|
help='Describe the changes made',
|
||||||
compute=lambda x: x,
|
compute=lambda x: x,
|
||||||
inverse=lambda x: x,
|
inverse=lambda x: x,
|
||||||
@ -124,10 +133,12 @@ class DocumentPage(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def _inverse_content(self):
|
def _inverse_content(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if rec.type == 'content':
|
if rec.type == 'content' and \
|
||||||
|
rec.content != rec.history_head.content:
|
||||||
rec._create_history({
|
rec._create_history({
|
||||||
|
'name': rec.draft_name,
|
||||||
|
'summary': rec.draft_summary,
|
||||||
'content': rec.content,
|
'content': rec.content,
|
||||||
'summary': rec.summary,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
@ -14,8 +14,9 @@ class DocumentPageHistory(models.Model):
|
|||||||
_order = 'id DESC'
|
_order = 'id DESC'
|
||||||
|
|
||||||
page_id = fields.Many2one('document.page', 'Page', ondelete='cascade')
|
page_id = fields.Many2one('document.page', 'Page', ondelete='cascade')
|
||||||
summary = fields.Char('Summary', index=True)
|
name = fields.Char(index=True)
|
||||||
content = fields.Text("Content")
|
summary = fields.Char(index=True)
|
||||||
|
content = fields.Text()
|
||||||
diff = fields.Text(compute='_compute_diff')
|
diff = fields.Text(compute='_compute_diff')
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
@ -54,17 +54,21 @@
|
|||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page name="content" string="Content">
|
<page name="content" string="Content">
|
||||||
<label for="summary" class="oe_edit_only"/>
|
<group string="Revision" class="oe_edit_only">
|
||||||
<field name="summary" placeholder="eg: Changed ... for ..." class="oe_edit_only"/>
|
<field name="draft_name" placeholder="Rev 01" class="oe_edit_only" />
|
||||||
<label for="content" class="oe_edit_only"/>
|
<field name="draft_summary" placeholder="eg: Changed ... for ..." class="oe_edit_only" />
|
||||||
<field name="content" widget="html" placeholder="e.g. Once upon a time..." required="1"
|
</group>
|
||||||
options="{'safe': True}"/>
|
<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>
|
||||||
<page name="history" string="History">
|
<page name="history" string="History">
|
||||||
<field name="history_ids">
|
<field name="history_ids">
|
||||||
<tree>
|
<tree>
|
||||||
<field name="id"/>
|
<field name="id"/>
|
||||||
<field name="create_date"/>
|
<field name="create_date"/>
|
||||||
|
<field name="name"/>
|
||||||
<field name="summary"/>
|
<field name="summary"/>
|
||||||
<field name="create_uid"/>
|
<field name="create_uid"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
<tree string="Document History">
|
<tree string="Document History">
|
||||||
<field name="id"/>
|
<field name="id"/>
|
||||||
<field name="page_id"/>
|
<field name="page_id"/>
|
||||||
|
<field name="name"/>
|
||||||
<field name="summary"/>
|
<field name="summary"/>
|
||||||
<field name="create_uid"/>
|
<field name="create_uid"/>
|
||||||
<field name="create_date"/>
|
<field name="create_date"/>
|
||||||
@ -46,11 +47,12 @@
|
|||||||
<field name="create_date" readonly="1"/>
|
<field name="create_date" readonly="1"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="name" placeholder="Rev 01"/>
|
||||||
|
<field name="summary" placeholder="eg: Changed ... for ..."/>
|
||||||
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page name="content" string="Content">
|
<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}"/>
|
<field name="content" widget="html" placeholder="e.g. Once upon a time..." options="{'safe': True}"/>
|
||||||
</page>
|
</page>
|
||||||
<page name="diff" string="Changes">
|
<page name="diff" string="Changes">
|
||||||
|
Loading…
Reference in New Issue
Block a user