mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-22 20:12:04 -06:00
show last approved content and aproved by
(../7.0pageapproval/ rev 4)
This commit is contained in:
parent
6af089e798
commit
877beb8746
@ -19,6 +19,7 @@
|
|||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
from openerp.osv import fields, orm
|
from openerp.osv import fields, orm
|
||||||
|
from datetime import *
|
||||||
|
|
||||||
class document_page_history_wkfl(orm.Model):
|
class document_page_history_wkfl(orm.Model):
|
||||||
_inherit = 'document.page.history'
|
_inherit = 'document.page.history'
|
||||||
@ -26,6 +27,8 @@ class document_page_history_wkfl(orm.Model):
|
|||||||
'state': fields.selection([
|
'state': fields.selection([
|
||||||
('draft','Draft'),
|
('draft','Draft'),
|
||||||
('approved','Approved')], 'Status', readonly=True),
|
('approved','Approved')], 'Status', readonly=True),
|
||||||
|
'approved_date': fields.datetime("Approved Date"),
|
||||||
|
'approved_uid': fields.many2one('res.users', "Approved By"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def page_approval_draft(self, cr, uid, ids):
|
def page_approval_draft(self, cr, uid, ids):
|
||||||
@ -33,7 +36,10 @@ class document_page_history_wkfl(orm.Model):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def page_approval_approved(self, cr, uid, ids):
|
def page_approval_approved(self, cr, uid, ids):
|
||||||
self.write(cr, uid, ids, { 'state' : 'approved' })
|
self.write(cr, uid, ids, { 'state' : 'approved',
|
||||||
|
'approved_date' : datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
|
'approved_uid': uid
|
||||||
|
})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@ -45,11 +51,39 @@ class document_page_approval(orm.Model):
|
|||||||
if page.type == "category":
|
if page.type == "category":
|
||||||
content = self._get_page_index(cr, uid, page, link=False)
|
content = self._get_page_index(cr, uid, page, link=False)
|
||||||
else:
|
else:
|
||||||
content = page.content
|
history = self.pool.get('document.page.history')
|
||||||
|
history_ids = history.search(cr, uid,[('page_id', '=', page.id), ('state', '=', 'approved')], limit=1, order='create_date DESC')
|
||||||
|
for h in history.browse(cr, uid, history_ids):
|
||||||
|
content = h.content
|
||||||
res[page.id] = content
|
res[page.id] = content
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def _get_approved_date(self, cr, uid, ids, name, args, context=None):
|
||||||
|
res = {}
|
||||||
|
for i in ids:
|
||||||
|
history = self.pool.get('document.page.history')
|
||||||
|
history_ids = history.search(cr, uid,[('page_id', '=', i), ('state', '=', 'approved')], limit=1, order='create_date DESC')
|
||||||
|
for h in history.browse(cr, uid, history_ids):
|
||||||
|
approved_date = h.approved_date
|
||||||
|
res[i] = approved_date
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
def _get_approved_uid(self, cr, uid, ids, name, args, context=None):
|
||||||
|
res = {}
|
||||||
|
for i in ids:
|
||||||
|
history = self.pool.get('document.page.history')
|
||||||
|
history_ids = history.search(cr, uid,[('page_id', '=', i), ('state', '=', 'approved')], limit=1, order='create_date DESC')
|
||||||
|
for h in history.browse(cr, uid, history_ids):
|
||||||
|
approved_uid = h.approved_uid.id
|
||||||
|
res[i] = approved_uid
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'display_content': fields.function(_get_display_content, string='Displayed Content', type='text')
|
'display_content': fields.function(_get_display_content, string='Displayed Content', type='text'),
|
||||||
|
'approved_date': fields.function(_get_approved_date, string="Approved Date", type='datetime'),
|
||||||
|
'approved_uid': fields.function(_get_approved_uid, string="Approved By", type='many2one', obj='res.users'),
|
||||||
}
|
}
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<openerp>
|
<openerp>
|
||||||
<data>
|
<data>
|
||||||
<!-- wiki Form view -->
|
|
||||||
<record id="wiki_history_form_inherit" model="ir.ui.view">
|
<record id="wiki_history_form_inherit" model="ir.ui.view">
|
||||||
<field name="name">document.page.history.form</field>
|
<field name="name">document.page.history.form</field>
|
||||||
<field name="model">document.page.history</field>
|
<field name="model">document.page.history</field>
|
||||||
@ -15,6 +14,18 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="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"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="display_content" position="before">
|
||||||
|
<field name="approved_date" class="oe_view_only"/>
|
||||||
|
<field name="approved_uid" class="oe_view_only"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
Loading…
Reference in New Issue
Block a user