[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:
Iván Todorovich
2018-04-20 10:42:10 -03:00
committed by Holger Brunn
parent 1528b490c8
commit c2a78a3c0d
4 changed files with 31 additions and 12 deletions

View File

@@ -43,7 +43,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,
@@ -139,10 +148,12 @@ class DocumentPage(models.Model):
@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

View File

@@ -15,8 +15,9 @@ 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