change approval workflow in page history and started to add showing approved page in normal page

(../7.0pageapproval/ rev 3)
This commit is contained in:
Jonatan Cloutier 2013-04-17 17:37:37 -04:00
parent 757ffe08ec
commit 6af089e798
3 changed files with 30 additions and 14 deletions

View File

@ -20,8 +20,8 @@
##############################################################################
from openerp.osv import fields, orm
class document_page_wkfl(orm.Model):
_inherit = 'document.page'
class document_page_history_wkfl(orm.Model):
_inherit = 'document.page.history'
_columns = {
'state': fields.selection([
('draft','Draft'),
@ -35,5 +35,21 @@ class document_page_wkfl(orm.Model):
def page_approval_approved(self, cr, uid, ids):
self.write(cr, uid, ids, { 'state' : 'approved' })
return True
class document_page_approval(orm.Model):
_inherit = 'document.page'
def _get_display_content(self, cr, uid, ids, name, args, context=None):
res = {}
for page in self.browse(cr, uid, ids, context=context):
if page.type == "category":
content = self._get_page_index(cr, uid, page, link=False)
else:
content = page.content
res[page.id] = content
return res
_columns = {
'display_content': fields.function(_get_display_content, string='Displayed Content', type='text')
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -2,17 +2,17 @@
<openerp>
<data>
<!-- wiki Form view -->
<record id="view_wiki_form_inherit" model="ir.ui.view">
<field name="name">document.page.form</field>
<field name="model">document.page</field>
<field name="inherit_id" ref="document_page.view_wiki_form"/>
<record id="wiki_history_form_inherit" model="ir.ui.view">
<field name="name">document.page.history.form</field>
<field name="model">document.page.history</field>
<field name="inherit_id" ref="document_page.wiki_history_form"/>
<field name="arch" type="xml">
<field name="type" position="before" >
<xpath expr="//form/label[@for='page_id']" position="before">
<header>
<button name="page_approval_approve" string="Approve" states="draft" />
<field name="state" widget="statusbar" statusbar_visible="draft,approved"/>
</header>
</field>
</xpath>
</field>
</record>

View File

@ -1,14 +1,14 @@
<?xml version="1.0"?>
<openerp>
<data>
<record model="workflow" id="wkf_document_page_aproval">
<field name="name">document.page.aproval.wkf</field>
<field name="osv">document.page</field>
<record model="workflow" id="wkf_document_page_history_aproval">
<field name="name">document.page.history.aproval.wkf</field>
<field name="osv">document.page.history</field>
<field name="on_create">True</field>
</record>
<record model="workflow.activity" id="act_draft">
<field name="wkf_id" ref="wkf_document_page_aproval" />
<field name="wkf_id" ref="wkf_document_page_history_aproval" />
<field name="flow_start">True</field>
<field name="name">draft</field>
<field name="kind">function</field>
@ -16,7 +16,7 @@
</record>
<record model="workflow.activity" id="act_approved">
<field name="wkf_id" ref="wkf_document_page_aproval" />
<field name="wkf_id" ref="wkf_document_page_history_aproval" />
<field name="name">approved</field>
<field name="kind">function</field>
<field name="action">page_approval_approved()</field>