mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-19 03:42:19 -06:00
[IMP] document_page_reference: auto-fill reference when not supplied.
also, make reference optional in tree view and not the first field.
This commit is contained in:
@@ -39,3 +39,19 @@ class TestDocumentReference(TransactionCase):
|
||||
def test_no_reference(self):
|
||||
self.page2.reference = "r3"
|
||||
self.assertRegex(self.page1.content_parsed, ".*r2.*")
|
||||
|
||||
def test_auto_reference(self):
|
||||
"""Test if reference is proposed when saving a page without one."""
|
||||
self.assertEqual(self.page1.reference, "R1")
|
||||
new_page = self.page_obj.create(
|
||||
{"name": "Test Page with no rEfErenCe", "content": "some content"}
|
||||
)
|
||||
self.assertEqual(new_page.reference, "test_page_with_no_reference")
|
||||
new_page_duplicated_name = self.page_obj.create(
|
||||
{
|
||||
"name": "test page with no reference",
|
||||
"content": "this should have an empty reference "
|
||||
"because reference must be unique",
|
||||
}
|
||||
)
|
||||
self.assertFalse(new_page_duplicated_name.reference)
|
||||
|
||||
Reference in New Issue
Block a user