test bug fixed

This commit is contained in:
Gervais Naoussi 2016-03-22 11:14:00 +01:00
parent 84d81949d7
commit 00788554f4
4 changed files with 29 additions and 16 deletions

View File

@ -5,8 +5,7 @@
<data noupdate="1">
<record id="email_template_new_draft_need_approval"
model="mail.template">
<record id="email_template_new_draft_need_approval" model="mail.template">
<field name="name">Automated new draft need approval Notification Mail</field>
<field name="email_from">${object.create_uid.company_id.email or 'noreply@localhost.com'}</field>
<field name="subject">New version of "${object.page_id.name}" to approve</field>
@ -14,7 +13,8 @@
<field name="model_id" ref="model_document_page_history"/>
<field name="auto_delete" eval="True"/>
<field name="lang">${object.create_uid.partner_id.lang}</field>
<field name="body_html"><![CDATA[
<field name="body_html">
<![CDATA[
<p>Hello,</p>
<p>The page "${object.page_id.name}" has been modified and need your approval.</p>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<record id="base.group_document_approver_user" model="res.groups">
<record id="group_document_approver_user" model="res.groups">
<field name="name">Document approver</field>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>

View File

@ -22,7 +22,7 @@ class TestDocumentPageApproval(common.TransactionCase):
self.assertIsNotNone(page.display_content, 'Page content')
# Check if approval is required
self.assertFalse(page.is_approval_required(page))
self.assertTrue(page.is_approval_required(page) == category.approval_required)
# Check content of an approval page
page.approval_required = True

View File

@ -12,17 +12,30 @@ class TestDocumentPageHistoryWorkflow(common.TransactionCase):
def test_can_user_approve_this_page(self):
"""Test if a user can approve this page."""
user = self.env.user
group = self.env['res.groups'].search([
('name', '=', 'Document approver')
])
category = self.env.ref('document_page.demo_category1')
category.approval_required = True
category.approver_uid = user
category.approver_uid = group
pages = self.env['document.page.history'].search([
('page_id', '=', category.id)
])
page = pages[0]
page = self.env['document.page'].create({
'name': 'Test Page10',
'parent_id': category.id
})
self.assertTrue(page.can_user_approve)
# history = self.env['document.page.history']
# history_ids = history.search(
# [
# ('page_id', '=', page.id)
# ],
# limit=1,
# order='create_date DESC'
#)
#history_ids.signal_workflow('page_approval_draft')
#state = history_ids.state == 'draft'
# state = history_ids[0].page_id == page.id
self.assertTrue(page.is_approval_required(page))
def test_get_approvers_guids(self):
"""Get approver guids."""
@ -30,7 +43,7 @@ class TestDocumentPageHistoryWorkflow(common.TransactionCase):
category.approval_required = True
pages = self.env['document.page.history'].search([
('page_id', '=', category.id)
])
])
page = pages[0]
approvers_guid = page.get_approvers_guids()
self.assertTrue(len(approvers_guid) > 0)
@ -41,7 +54,7 @@ class TestDocumentPageHistoryWorkflow(common.TransactionCase):
category.approval_required = True
pages = self.env['document.page.history'].search([
('page_id', '=', category.id)
])
])
page = pages[0]
_logger.info("Email: " + str(page.get_approvers_email))
self.assertIsNotNone(page.get_approvers_email)
@ -52,7 +65,7 @@ class TestDocumentPageHistoryWorkflow(common.TransactionCase):
category.approval_required = True
pages = self.env['document.page.history'].search([
('page_id', '=', category.id)
])
])
page = pages[0]
_logger.info("Page: "+str(page.get_page_url))
_logger.info("Page: " + str(page.get_page_url))
self.assertIsNotNone(page.get_page_url)