FIX Last Contributor (uid and date). Use related fields instead of computed where possible.

Fix search views, store some fields to make them searchable, added filters
This commit is contained in:
Iván Todorovich 2018-03-01 11:45:45 -03:00
parent 2b4327751f
commit dbeec6ef0f
9 changed files with 323 additions and 255 deletions

View File

@ -37,6 +37,8 @@
'wizard/document_page_create_menu.xml', 'wizard/document_page_create_menu.xml',
'wizard/document_page_show_diff.xml', 'wizard/document_page_show_diff.xml',
'views/document_page.xml', 'views/document_page.xml',
'views/document_page_category.xml',
'views/document_page_history.xml',
'views/document_page_assets.xml', 'views/document_page_assets.xml',
'views/report_document_page.xml', 'views/report_document_page.xml',
'security/document_page_security.xml', 'security/document_page_security.xml',

View File

@ -55,6 +55,7 @@ class DocumentPage(models.Model):
"Content", "Content",
compute='_compute_content', compute='_compute_content',
inverse='_inverse_content', inverse='_inverse_content',
search='_search_content',
required=True, required=True,
) )
@ -78,12 +79,20 @@ class DocumentPage(models.Model):
compute='_compute_display_content' compute='_compute_display_content'
) )
history_head = fields.Many2one(
'document.page.history',
'HEAD',
compute='_compute_history_head',
store=True,
auto_join=True,
)
history_ids = fields.One2many( history_ids = fields.One2many(
'document.page.history', 'document.page.history',
'page_id', 'page_id',
'History', 'History',
order='create_date DESC', order='create_date DESC',
readonly=True readonly=True,
) )
menu_id = fields.Many2one( menu_id = fields.Many2one(
@ -92,29 +101,21 @@ class DocumentPage(models.Model):
readonly=True readonly=True
) )
create_date = fields.Datetime( content_date = fields.Datetime(
"Created on", 'Last Contribution Date',
related='history_head.create_date',
store=True,
index=True, index=True,
readonly=True readonly=True,
) )
create_uid = fields.Many2one( content_uid = fields.Many2one(
'res.users', 'res.users',
'Author', 'Last Contributor',
related='history_head.create_uid',
store=True,
index=True, index=True,
readonly=True readonly=True,
)
write_date = fields.Datetime(
"Modification Date",
index=True,
readonly=True)
write_uid = fields.Many2one(
'res.users',
"Last Contributor",
index=True,
readonly=True
) )
@api.multi @api.multi
@ -133,19 +134,21 @@ class DocumentPage(models.Model):
return r return r
@api.multi @api.multi
@api.depends('content')
def _compute_display_content(self): def _compute_display_content(self):
# @deprecated, simply use content # @deprecated, simply use content
for rec in self: for rec in self:
rec.display_content = rec.content rec.display_content = rec.content
@api.multi @api.multi
@api.depends('history_head', 'history_ids')
def _compute_content(self): def _compute_content(self):
for rec in self: for rec in self:
if rec.type == 'category': if rec.type == 'category':
rec.content = rec._get_page_index(link=False) rec.content = rec._get_page_index(link=False)
else: else:
if rec.history_ids: if rec.history_head:
rec.content = rec.history_ids[0].content rec.content = rec.history_head.content
else: else:
# html widget's default, so it doesn't trigger ghost save # html widget's default, so it doesn't trigger ghost save
rec.content = '<p><br></p>' rec.content = '<p><br></p>'
@ -159,6 +162,17 @@ class DocumentPage(models.Model):
'summary': rec.summary, 'summary': rec.summary,
}) })
@api.multi
def _search_content(self, operator, value):
return [('history_head.content', operator, value)]
@api.multi
@api.depends('history_ids')
def _compute_history_head(self):
for rec in self:
if rec.history_ids:
rec.history_head = rec.history_ids[0]
@api.multi @api.multi
def _create_history(self, vals): def _create_history(self, vals):
self.ensure_one() self.ensure_one()

View File

@ -28,7 +28,6 @@ class DocumentPageHistory(models.Model):
_name = "document.page.history" _name = "document.page.history"
_description = "Document Page History" _description = "Document Page History"
_order = 'id DESC' _order = 'id DESC'
_rec_name = "create_date"
page_id = fields.Many2one('document.page', 'Page', ondelete='cascade') page_id = fields.Many2one('document.page', 'Page', ondelete='cascade')
summary = fields.Char('Summary', index=True) summary = fields.Char('Summary', index=True)

View File

@ -1,10 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<odoo> <odoo>
<data> <data>
<menuitem name="Pages"
id="menu_wiki"
parent="knowledge.menu_document"
sequence="20" />
<!-- wiki tree view --> <!-- wiki tree view -->
<record id="view_wiki_tree_children" model="ir.ui.view"> <record id="view_wiki_tree_children" model="ir.ui.view">
@ -15,8 +12,8 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Document Page"> <tree string="Document Page">
<field name="name"/> <field name="name"/>
<field name="write_uid"/> <field name="content_uid"/>
<field name="write_date"/> <field name="content_date"/>
</tree> </tree>
</field> </field>
</record> </record>
@ -30,8 +27,8 @@
<field name="name"/> <field name="name"/>
<field name="parent_id"/> <field name="parent_id"/>
<field name="create_uid" invisible="1"/> <field name="create_uid" invisible="1"/>
<field name="write_uid"/> <field name="content_uid"/>
<field name="write_date"/> <field name="content_date"/>
</tree> </tree>
</field> </field>
</record> </record>
@ -50,8 +47,8 @@
<field name="parent_id" string="Category" context="{'default_type':'category'}"/> <field name="parent_id" string="Category" context="{'default_type':'category'}"/>
</group> </group>
<group> <group>
<field name="write_uid" readonly="1"/> <field name="content_uid"/>
<field name="write_date" readonly="1"/> <field name="content_date"/>
<field name="menu_id" readonly="1" attrs="{'invisible': [('menu_id','=',False)]}"/> <field name="menu_id" readonly="1" attrs="{'invisible': [('menu_id','=',False)]}"/>
</group> </group>
</group> </group>
@ -59,8 +56,8 @@
<page name="content" string="Content"> <page name="content" string="Content">
<label for="summary" class="oe_edit_only" /> <label for="summary" class="oe_edit_only" />
<field name="summary" placeholder="eg: Changed ... for ..." class="oe_edit_only" /> <field name="summary" placeholder="eg: Changed ... for ..." class="oe_edit_only" />
<label for="content" class="oe_edit_only" /> <label for="content" class="oe_edit_only"/>
<field name="content" widget="html" placeholder="e.g. Once upon a time..." options="{'safe': True}"/> <field name="content" widget="html" placeholder="e.g. Once upon a time..." required="1" options="{'safe': True}"/>
</page> </page>
<page name="history" string="History"> <page name="history" string="History">
<field name="history_ids"> <field name="history_ids">
@ -89,7 +86,7 @@
<form string="Document Page"> <form string="Document Page">
<field name="type" invisible="1"/> <field name="type" invisible="1"/>
<h1><field name="name" placeholder="Name"/></h1> <h1><field name="name" placeholder="Name"/></h1>
<field name="content" class="oe_view_only" options='{"safe": True}'/> <field name="content" class="oe_view_only" required="1" options='{"safe": True}'/>
</form> </form>
</field> </field>
</record> </record>
@ -100,72 +97,19 @@
<field name="model">document.page</field> <field name="model">document.page</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<search string="Document Page"> <search string="Document Page">
<field name="name" string="Content" <field name="name" string="Content" filter_domain="['|', ('name','ilike',self), ('content','ilike',self)]"/>
filter_domain="['|', ('name','ilike',self), ('content','ilike',self)]"/>
<field name="write_uid"/>
<field name="parent_id"/> <field name="parent_id"/>
<field name="create_uid"/>
<field name="content_uid"/>
<group expand="0" string="Group By..."> <group expand="0" string="Group By...">
<filter string="Document Type" context="{'group_by':'parent_id'}" /> <filter string="Category" context="{'group_by':'parent_id'}" />
<filter string="Author" context="{'group_by':'create_uid'}" /> <filter string="Author" context="{'group_by':'create_uid'}" />
<filter string="Last Contributor" context="{'group_by':'write_uid'}" /> <filter string="Last Contributor" context="{'group_by':'content_uid'}" />
</group> </group>
</search> </search>
</field> </field>
</record> </record>
<!-- Category Views -->
<record id="view_category_form" model="ir.ui.view">
<field name="name">document.page.category.form</field>
<field name="model">document.page</field>
<field name="arch" type="xml">
<form string="Category">
<sheet>
<field name="type" invisible="1"/>
<h1><field name="name" placeholder="Name"/></h1>
<group>
<group>
<field name="parent_id" string="Category"
context="{'default_type':'category'}"/>
</group>
<group>
<field name="write_uid"
groups="base.group_no_one"/>
<field name="write_date"
groups="base.group_no_one"/>
<field name="menu_id"
groups="base.group_no_one"/>
</group>
</group>
<notebook>
<page string="Template" name="template">
<field name="template" placeholder="e.g. Once upon a time..." />
</page>
<page string="Documents" name="documents">
<field name="content" widget="html" class="oe_view_only" options='{"safe": True}' />
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>
<record id="view_category_tree" model="ir.ui.view">
<field name="name">document.page.category.tree</field>
<field name="model">document.page</field>
<field name="arch" type="xml">
<tree string="Categories">
<field name="name"/>
<field name="parent_id"/>
<field name="create_uid" invisible="1"/>
<field name="write_uid"/>
<field name="write_date"/>
</tree>
</field>
</record>
<!-- page action --> <!-- page action -->
<record id="action_page" model="ir.actions.act_window"> <record id="action_page" model="ir.actions.act_window">
@ -183,135 +127,35 @@
</p> </p>
</field> </field>
</record> </record>
<record id="action_page_view_tree" model="ir.actions.act_window.view"> <record id="action_page_view_tree" model="ir.actions.act_window.view">
<field name="sequence" eval="0" /> <field name="sequence" eval="0" />
<field name="view_mode">tree</field> <field name="view_mode">tree</field>
<field name="view_id" ref="view_wiki_tree"/> <field name="view_id" ref="view_wiki_tree"/>
<field name="act_window_id" ref="action_page"/> <field name="act_window_id" ref="action_page"/>
</record> </record>
<record id="action_page_view_form" model="ir.actions.act_window.view"> <record id="action_page_view_form" model="ir.actions.act_window.view">
<field name="sequence" eval="5" /> <field name="sequence" eval="5" />
<field name="view_mode">form</field> <field name="view_mode">form</field>
<field name="view_id" ref="view_wiki_form"/> <field name="view_id" ref="view_wiki_form"/>
<field name="act_window_id" ref="action_page"/> <field name="act_window_id" ref="action_page"/>
</record> </record>
<menuitem id="menu_page"
parent="menu_wiki"
<menuitem id="menu_wiki"
name="Pages" name="Pages"
parent="knowledge.menu_document"
sequence="20" />
<menuitem id="menu_page"
name="Pages"
parent="menu_wiki"
action="action_page" action="action_page"
sequence="10" /> sequence="10" />
<record id="action_category" model="ir.actions.act_window">
<field name="name">Category</field>
<field name="res_model">document.page</field>
<field name="domain">[('type','=','category')]</field>
<field name="context">{'default_type': 'category'}</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_category_tree"/>
<field name="search_view_id" ref="view_wiki_filter"/>
</record>
<record id="action_category_view_tree" model="ir.actions.act_window.view">
<field name="sequence" eval="0" />
<field name="view_mode">tree</field>
<field name="view_id" ref="view_category_tree"/>
<field name="act_window_id" ref="action_category"/>
</record>
<record id="action_category_view_form" model="ir.actions.act_window.view">
<field name="sequence" eval="5" />
<field name="view_mode">form</field>
<field name="view_id" ref="view_category_form"/>
<field name="act_window_id" ref="action_category"/>
</record>
<menuitem id="menu_category"
parent="menu_wiki"
name="Categories"
action="action_category"
sequence="20"/>
<!-- History Tree view -->
<record model="ir.ui.view" id="view_wiki_history_tree">
<field name="name">document.page.history.tree</field>
<field name="model">document.page.history</field>
<field name="arch" type="xml">
<tree string="Document History">
<field name="id"/>
<field name="page_id"/>
<field name="summary"/>
<field name="create_uid"/>
<field name="create_date"/>
</tree>
</field>
</record>
<!-- History Search view -->
<record id="view_wiki_history_filter" model="ir.ui.view">
<field name="name">document.page.history.search</field>
<field name="model">document.page.history</field>
<field name="arch" type="xml">
<search string="Document Page History">
<field name="page_id"/>
<field name="content"/>
<field name="create_uid"/>
<group expand="0" string="Group By...">
<filter name="group_author" string="Author" context="{'group_by':'create_uid'}" />
</group>
</search>
</field>
</record>
<!-- History Form view -->
<record model="ir.ui.view" id="wiki_history_form">
<field name="name">document.page.history.form</field>
<field name="model">document.page.history</field>
<field name="arch" type="xml">
<form string="Document Page History">
<sheet>
<h1><field name="page_id"/></h1>
<group>
<group>
<field name="create_uid" readonly="1"/>
<field name="create_date" readonly="1"/>
</group>
</group>
<notebook>
<page name="content" string="Content">
<label for="summary"/>
<field name="summary" placeholder="eg: Changed ... for ..."/>
<label for="content"/>
<field name="content" widget="html" placeholder="e.g. Once upon a time..." options="{'safe': True}"/>
</page>
<page name="diff" string="Changes">
<field name="diff" widget="html" style="overflow-x: scroll" />
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<!-- History Action -->
<record model="ir.actions.act_window" id="action_history">
<field name="name">Page history</field>
<field name="res_model">document.page.history</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="menu_page_history"
parent="menu_wiki"
name="Pages history"
action="action_history"
sequence="30"
groups="base.group_no_one" />
<act_window
id="action_related_page_history"
context="{'search_default_page_id': [active_id], 'default_page_id': active_id}"
domain="[('page_id','=',active_id)]"
name="Page History"
res_model="document.page.history"
src_model="document.page"/>
<act_window <act_window
id="action_related_page_create_menu" id="action_related_page_create_menu"

View File

@ -0,0 +1,90 @@
<?xml version="1.0"?>
<odoo>
<data>
<!-- Category Views -->
<record id="view_category_form" model="ir.ui.view">
<field name="name">document.page.category.form</field>
<field name="model">document.page</field>
<field name="arch" type="xml">
<form string="Category">
<sheet>
<field name="type" invisible="1"/>
<h1><field name="name" placeholder="Name"/></h1>
<group>
<group>
<field name="parent_id" string="Category" context="{'default_type':'category'}"/>
</group>
<group>
<field name="write_uid" groups="base.group_no_one"/>
<field name="write_date" groups="base.group_no_one"/>
<field name="menu_id" groups="base.group_no_one"/>
</group>
</group>
<notebook>
<page string="Template" name="template">
<field name="template" placeholder="e.g. Once upon a time..." />
</page>
<page string="Documents" name="documents">
<field name="content" widget="html" class="oe_view_only" options='{"safe": True}' />
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>
<record id="view_category_tree" model="ir.ui.view">
<field name="name">document.page.category.tree</field>
<field name="model">document.page</field>
<field name="arch" type="xml">
<tree string="Categories">
<field name="name"/>
<field name="parent_id"/>
<field name="create_uid" invisible="1"/>
<field name="write_uid"/>
<field name="write_date"/>
</tree>
</field>
</record>
<!-- category Action -->
<record id="action_category" model="ir.actions.act_window">
<field name="name">Category</field>
<field name="res_model">document.page</field>
<field name="domain">[('type','=','category')]</field>
<field name="context">{'default_type': 'category'}</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_category_tree"/>
<field name="search_view_id" ref="view_wiki_filter"/>
</record>
<record id="action_category_view_tree" model="ir.actions.act_window.view">
<field name="sequence" eval="0" />
<field name="view_mode">tree</field>
<field name="view_id" ref="view_category_tree"/>
<field name="act_window_id" ref="action_category"/>
</record>
<record id="action_category_view_form" model="ir.actions.act_window.view">
<field name="sequence" eval="5" />
<field name="view_mode">form</field>
<field name="view_id" ref="view_category_form"/>
<field name="act_window_id" ref="action_category"/>
</record>
<menuitem id="menu_category"
parent="menu_wiki"
name="Categories"
action="action_category"
sequence="20"/>
</data>
</odoo>

View File

@ -0,0 +1,90 @@
<?xml version="1.0"?>
<odoo>
<data>
<!-- History Tree view -->
<record model="ir.ui.view" id="view_wiki_history_tree">
<field name="name">document.page.history.tree</field>
<field name="model">document.page.history</field>
<field name="arch" type="xml">
<tree string="Document History">
<field name="id"/>
<field name="page_id"/>
<field name="summary"/>
<field name="create_uid"/>
<field name="create_date"/>
</tree>
</field>
</record>
<!-- History Search view -->
<record id="view_wiki_history_filter" model="ir.ui.view">
<field name="name">document.page.history.search</field>
<field name="model">document.page.history</field>
<field name="arch" type="xml">
<search string="Document Page History">
<field name="page_id"/>
<field name="content"/>
<field name="create_uid"/>
<group expand="0" string="Group By...">
<filter name="group_author" string="Author" context="{'group_by':'create_uid'}" />
</group>
</search>
</field>
</record>
<!-- History Form view -->
<record model="ir.ui.view" id="wiki_history_form">
<field name="name">document.page.history.form</field>
<field name="model">document.page.history</field>
<field name="arch" type="xml">
<form string="Document Page History">
<sheet>
<h1><field name="page_id"/></h1>
<group>
<group>
<field name="create_uid" readonly="1"/>
<field name="create_date" readonly="1"/>
</group>
</group>
<notebook>
<page name="content" string="Content">
<label for="summary"/>
<field name="summary" placeholder="eg: Changed ... for ..."/>
<label for="content"/>
<field name="content" widget="html" placeholder="e.g. Once upon a time..." options="{'safe': True}"/>
</page>
<page name="diff" string="Changes">
<field name="diff" widget="html" style="overflow-x: scroll" />
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<!-- History Action -->
<record model="ir.actions.act_window" id="action_history">
<field name="name">Page history</field>
<field name="res_model">document.page.history</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="menu_page_history"
parent="menu_wiki"
name="Pages history"
action="action_history"
sequence="30"
groups="base.group_no_one" />
<act_window id="action_related_page_history"
context="{'search_default_page_id': [active_id], 'default_page_id': active_id}"
domain="[('page_id','=',active_id)]"
name="Page History"
res_model="document.page.history"
src_model="document.page"/>
</data>
</odoo>

View File

@ -34,14 +34,20 @@ class DocumentPageApproval(models.Model):
) )
approved_date = fields.Datetime( approved_date = fields.Datetime(
compute='_compute_approved_info', 'Approved Date',
string="Approved Date" related='history_head.approved_date',
store=True,
index=True,
readonly=True,
) )
approved_uid = fields.Many2one( approved_uid = fields.Many2one(
'res.users', 'res.users',
compute='_compute_approved_info', 'Approved by',
string="Approved By", related='history_head.approved_uid',
store=True,
index=True,
readonly=True,
) )
approval_required = fields.Boolean( approval_required = fields.Boolean(
@ -61,6 +67,10 @@ class DocumentPageApproval(models.Model):
compute='_compute_is_approval_required', compute='_compute_is_approval_required',
) )
am_i_approver = fields.Boolean(
compute='_compute_am_i_approver'
)
approver_group_ids = fields.Many2many( approver_group_ids = fields.Many2many(
'res.groups', 'res.groups',
string='Approver groups', string='Approver groups',
@ -73,15 +83,6 @@ class DocumentPageApproval(models.Model):
string='Has changes pending approval' string='Has changes pending approval'
) )
@api.multi
@api.depends('history_ids')
def _compute_approved_info(self):
"""Return the approved date of a document."""
for page in self:
if page.history_ids:
page.approved_date = page.history_ids[0].approved_date
page.approved_uid = page.history_ids[0].approved_uid
@api.multi @api.multi
@api.depends('approval_required', 'parent_id.is_approval_required') @api.depends('approval_required', 'parent_id.is_approval_required')
def _compute_is_approval_required(self): def _compute_is_approval_required(self):
@ -102,6 +103,30 @@ class DocumentPageApproval(models.Model):
res = res | page.parent_id.approver_group_ids res = res | page.parent_id.approver_group_ids
page.approver_group_ids = res page.approver_group_ids = res
@api.multi
@api.depends('is_approval_required', 'approver_group_ids')
def _compute_am_i_approver(self):
"""Check if the current user can approve changes to this page."""
for rec in self:
rec.am_i_approver = rec.can_user_approve_this_page(self.env.user)
@api.multi
def can_user_approve_this_page(self, user):
"""Check if a user can approve this page."""
self.ensure_one()
# if it's not required, anyone can approve
if not self.is_approval_required:
return True
# to approve, you must have approver rights
approver_group_id = self.env.ref(
'document_page_approval.group_document_approver_user')
if approver_group_id not in user.groups_id:
return False
# and belong to at least one of the approver_groups (if any is set)
if not self.approver_group_ids:
return True
return len(user.groups_id & self.approver_group_ids) > 0
@api.multi @api.multi
def _compute_has_changes_pending_approval(self): def _compute_has_changes_pending_approval(self):
history = self.env['document.page.history'] history = self.env['document.page.history']

View File

@ -40,11 +40,13 @@ class DocumentPageHistoryWorkflow(models.Model):
readonly=True, readonly=True,
) )
approved_date = fields.Datetime("Approved Date") approved_date = fields.Datetime(
'Approved Date',
)
approved_uid = fields.Many2one( approved_uid = fields.Many2one(
'res.users', 'res.users',
"Approved By" 'Approved by',
) )
is_approval_required = fields.Boolean( is_approval_required = fields.Boolean(
@ -52,8 +54,13 @@ class DocumentPageHistoryWorkflow(models.Model):
string="Approval required", string="Approval required",
) )
am_i_owner = fields.Boolean(compute='_compute_am_i_owner') am_i_owner = fields.Boolean(
am_i_approver = fields.Boolean(compute='_compute_am_i_approver') compute='_compute_am_i_owner'
)
am_i_approver = fields.Boolean(
related='page_id.am_i_approver'
)
page_url = fields.Text( page_url = fields.Text(
compute='_compute_page_url', compute='_compute_page_url',
@ -92,6 +99,8 @@ class DocumentPageHistoryWorkflow(models.Model):
'approved_uid': self.env.uid 'approved_uid': self.env.uid
}) })
for rec in self: for rec in self:
# Trigger computed field update
rec.page_id._compute_history_head()
# Notify state change # Notify state change
rec.message_post( rec.message_post(
subtype='mt_comment', subtype='mt_comment',
@ -125,29 +134,6 @@ class DocumentPageHistoryWorkflow(models.Model):
for rec in self: for rec in self:
rec.am_i_owner = (rec.create_uid == self.env.user) rec.am_i_owner = (rec.create_uid == self.env.user)
@api.multi
def _compute_am_i_approver(self):
"""Check if the current user can approve the page."""
for rec in self:
rec.am_i_approver = rec.can_user_approve_this_page(self.env.user)
@api.multi
def can_user_approve_this_page(self, user):
"""Check if a user can approve this page."""
self.ensure_one()
# if it's not required, anyone can approve
if not self.is_approval_required:
return True
# to approve, you must have approver rights
approver_group_id = self.env.ref(
'document_page_approval.group_document_approver_user')
if approver_group_id not in user.groups_id:
return False
# and belong to at least one of the approver_groups (if any is set)
if not self.page_id.approver_group_ids:
return True
return len(user.groups_id & self.page_id.approver_group_ids) > 0
@api.multi @api.multi
def _compute_page_url(self): def _compute_page_url(self):
"""Compute the page url.""" """Compute the page url."""

View File

@ -1,5 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<odoo> <odoo>
<!-- History 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>
@ -46,6 +48,7 @@
</field> </field>
</record> </record>
<!-- Page Form View -->
<record id="wiki_form_inherit" model="ir.ui.view"> <record id="wiki_form_inherit" model="ir.ui.view">
<field name="name">document.page.form</field> <field name="name">document.page.form</field>
<field name="model">document.page</field> <field name="model">document.page</field>
@ -73,11 +76,11 @@
</div> </div>
</field> </field>
<field name="write_uid" position="after"> <field name="content_uid" position="after">
<field name="approved_uid"/> <field name="approved_uid"/>
</field> </field>
<field name="write_date" position="replace"> <field name="content_date" position="replace">
<field name="approved_date"/> <field name="approved_date"/>
</field> </field>
@ -94,6 +97,7 @@
</field> </field>
</record> </record>
<!-- Page Menu Form View -->
<record id="view_wiki_menu_form_inherit" model="ir.ui.view"> <record id="view_wiki_menu_form_inherit" model="ir.ui.view">
<field name="name">document.page.form</field> <field name="name">document.page.form</field>
<field name="model">document.page</field> <field name="model">document.page</field>
@ -108,6 +112,7 @@
</field> </field>
</record> </record>
<!-- Catgory Form View -->
<record id="view_category_form_inherit" model="ir.ui.view"> <record id="view_category_form_inherit" model="ir.ui.view">
<field name="name">document.page.category.form</field> <field name="name">document.page.category.form</field>
<field name="model">document.page</field> <field name="model">document.page</field>
@ -121,6 +126,7 @@
</field> </field>
</record> </record>
<!-- History Tree view -->
<record id="view_wiki_history_tree_inherit" model="ir.ui.view"> <record id="view_wiki_history_tree_inherit" model="ir.ui.view">
<field name="name">document.page.history.tree</field> <field name="name">document.page.history.tree</field>
<field name="model">document.page.history</field> <field name="model">document.page.history</field>
@ -149,6 +155,18 @@
<field name="page_id" position="before"> <field name="page_id" position="before">
<field name="state"/> <field name="state"/>
</field> </field>
<field name="create_uid" position="after">
<filter name="draft" string="Draft" domain="[('state','=','draft')]"/>
<filter name="pending" string="Pending Approval" domain="[('state','=','to approve')]"/>
<filter name="approved" string="Approved" domain="[('state','=','approved')]"/>
<filter name="cancelled" string="Cancelled" domain="[('state','=','cancelled')]"/>
</field>
<filter name="group_author" position="before">
<filter name="group_state" string="State" context="{'group_by':'state'}" />
</filter>
<filter name="group_author" position="after">
<filter name="group_approver" string="Approver" context="{'group_by':'approved_uid'}" />
</filter>
</field> </field>
</record> </record>
@ -162,8 +180,8 @@
</record> </record>
<menuitem id="menu_page_change_requests" <menuitem id="menu_page_change_requests"
parent="document_page.menu_wiki"
name="Change Requests" name="Change Requests"
parent="document_page.menu_wiki"
action="action_change_requests" action="action_change_requests"
sequence="25" sequence="25"
groups="document_page.group_document_editor" /> groups="document_page.group_document_editor" />