mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-19 03:42:19 -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.
[document_page] FIX BUG: UI hanging when editing content. This was due to the api.depends on _compute_diff. Removing it because it's not really necessary since the field is not stored. [document_page] page_id should be readonly. Improve active field [document_page] Update version number [UPD] Update document_page.pot [MIG] document_page_multi_company (#188) * [MIG] document_page_multi_company Added this feature from the old module directly in document_page
This commit is contained in:
committed by
FernandoRomera
parent
1125031c74
commit
10aafc1ea3
@@ -21,6 +21,8 @@ class DocumentPage(models.Model):
|
||||
default="content"
|
||||
)
|
||||
|
||||
active = fields.Boolean(default=True)
|
||||
|
||||
parent_id = fields.Many2one(
|
||||
'document.page',
|
||||
'Category',
|
||||
@@ -42,7 +44,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,
|
||||
@@ -93,6 +104,14 @@ class DocumentPage(models.Model):
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
company_id = fields.Many2one(
|
||||
'res.company',
|
||||
'Company',
|
||||
help='If set, page is accessible only from this company',
|
||||
index=True,
|
||||
ondelete='cascade',
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def _get_page_index(self, link=True):
|
||||
"""Return the index of a document."""
|
||||
@@ -124,10 +143,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
|
||||
|
||||
@@ -14,12 +14,22 @@ 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')
|
||||
|
||||
company_id = fields.Many2one(
|
||||
'res.company',
|
||||
'Company',
|
||||
help='If set, page is accessible only from this company',
|
||||
related='page_id.company_id',
|
||||
store=True,
|
||||
index=True,
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
@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']
|
||||
|
||||
Reference in New Issue
Block a user