mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-24 09:28:42 -06:00
[FIX] document_page: Broken recomputation lead to invalid history head
This commit is contained in:
parent
f621268181
commit
9977bdeaa7
@ -164,7 +164,10 @@ class DocumentPage(models.Model):
|
|||||||
def _compute_history_head(self):
|
def _compute_history_head(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if rec.history_ids:
|
if rec.history_ids:
|
||||||
rec.history_head = rec.history_ids[0]
|
# do not rely on the history_ids default order here as odoo 14.0 does
|
||||||
|
# not seems to comply with the default model order when recomputing.
|
||||||
|
# fixing it by running a new sort (basically a new search).
|
||||||
|
rec.history_head = rec.history_ids.sorted()[0]
|
||||||
else:
|
else:
|
||||||
rec.history_head = False
|
rec.history_head = False
|
||||||
|
|
||||||
|
@ -22,6 +22,10 @@ class TestDocumentPage(common.TransactionCase):
|
|||||||
self.assertEqual(len(page.history_ids), 1)
|
self.assertEqual(len(page.history_ids), 1)
|
||||||
page.content = "New content for Demo Page"
|
page.content = "New content for Demo Page"
|
||||||
self.assertEqual(len(page.history_ids), 2)
|
self.assertEqual(len(page.history_ids), 2)
|
||||||
|
page.content = "Another new content for Demo Page"
|
||||||
|
self.assertEqual(len(page.history_ids), 3)
|
||||||
|
# ensure history head is the latest revision (default sort order is ID DESC)
|
||||||
|
self.assertEqual(page.history_head.id, max(page.history_ids.ids))
|
||||||
|
|
||||||
def test_category_template(self):
|
def test_category_template(self):
|
||||||
page = self.page_obj.create(
|
page = self.page_obj.create(
|
||||||
|
Loading…
Reference in New Issue
Block a user