[REF] document_page: refactored the module, towards using it in website_blog
Main modifications: - category is now a blog.catory object, instead of a document.page with type='category' - added blog.tag model, to be able to tag posts - cleaned document.page, now blog.post model, removing type and unnecessary features - added chatter on blog.post, blog.category - added subtypes to enable direct follow of posts when following a category - updated document.page.history (now blog.post.history) - commented menu creation, because this does not seem to be necessary anymore considering the new website - updated wizard.document.page.history.show_diff, now blog.post.history.show_diff - updated all views accordingly, as well as demo data - removed the use of document_user group, simplified rules on blog.post (not done for new models) - misc cleaning Next step: merge with website_mail bzr revid: tde@openerp.com-20130920111221-qy3x5eoyih26axn8
This commit is contained in:
parent
8c265d7c98
commit
901f573826
|
@ -30,19 +30,25 @@ Web pages
|
|||
""",
|
||||
'author': ['OpenERP SA'],
|
||||
'website': 'http://www.openerp.com/',
|
||||
'depends': ['knowledge'],
|
||||
'depends': ['mail', 'knowledge'],
|
||||
'data': [
|
||||
'wizard/document_page_create_menu_view.xml',
|
||||
# 'wizard/document_page_create_menu_view.xml',
|
||||
'wizard/document_page_show_diff_view.xml',
|
||||
'document_page_view.xml',
|
||||
'security/document_page_security.xml',
|
||||
'document_page_data.xml',
|
||||
# 'security/document_page_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'demo': ['document_page_demo.xml'],
|
||||
'test': ['test/document_page_test00.yml'],
|
||||
'demo': [
|
||||
'document_page_demo.xml'
|
||||
],
|
||||
'test': [
|
||||
# 'test/document_page_test00.yml'
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
'images': [],
|
||||
'css' : ['static/src/css/document_page.css'],
|
||||
'css': [
|
||||
'static/src/css/document_page.css'
|
||||
],
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
# Copyright (C) 2004-Today OpenERP SA (<http://www.openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
|
@ -22,45 +22,56 @@
|
|||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
import difflib
|
||||
from openerp import tools
|
||||
|
||||
class document_page(osv.osv):
|
||||
_name = "document.page"
|
||||
_description = "Document Page"
|
||||
|
||||
class BlogCategory(osv.Model):
|
||||
_name = 'blog.category'
|
||||
_description = 'Blog Category'
|
||||
_inherit = ['mail.thread']
|
||||
_order = 'name'
|
||||
|
||||
def _get_page_index(self, cr, uid, page, link=True):
|
||||
index = []
|
||||
for subpage in page.child_ids:
|
||||
index += ["<li>"+ self._get_page_index(cr, uid, subpage) +"</li>"]
|
||||
r = ''
|
||||
if link:
|
||||
r = '<a href="#id=%s">%s</a>'%(page.id,page.name)
|
||||
if index:
|
||||
r += "<ul>" + "".join(index) + "</ul>"
|
||||
return r
|
||||
_columns = {
|
||||
'name': fields.char('Name', required=True),
|
||||
'description': fields.text('Description'),
|
||||
'template': fields.text('Template'),
|
||||
'blog_ids': fields.one2many(
|
||||
'blog.post', 'category_id',
|
||||
'Blogs',
|
||||
),
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
class BlogTag(osv.Model):
|
||||
_name = 'blog.tag'
|
||||
_description = 'Blog Tag'
|
||||
_order = 'name'
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', required=True),
|
||||
}
|
||||
|
||||
|
||||
class BlogPost(osv.Model):
|
||||
_name = "blog.post"
|
||||
_description = "Blog Post"
|
||||
_inherit = ['mail.thread']
|
||||
_order = 'name'
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Title', required=True),
|
||||
'type':fields.selection([('content','Content'), ('category','Category')], 'Type', help="Page type"),
|
||||
|
||||
'parent_id': fields.many2one('document.page', 'Category', domain=[('type','=','category')]),
|
||||
'child_ids': fields.one2many('document.page', 'parent_id', 'Children'),
|
||||
'category_id': fields.many2one(
|
||||
'blog.category', 'Category',
|
||||
ondelete='set null',
|
||||
),
|
||||
'tag_ids': fields.many2many(
|
||||
'blog.tag', 'blog_tag_rel',
|
||||
'blog_id', 'tag_id',
|
||||
'Tags',
|
||||
),
|
||||
|
||||
'content': fields.text("Content"),
|
||||
'display_content': fields.function(_get_display_content, string='Displayed Content', type='text'),
|
||||
|
||||
'history_ids': fields.one2many('document.page.history', 'page_id', 'History'),
|
||||
'history_ids': fields.one2many('blog.post.history', 'post_id', 'History'),
|
||||
'menu_id': fields.many2one('ir.ui.menu', "Menu", readonly=True),
|
||||
|
||||
'create_date': fields.datetime("Created on", select=True, readonly=True),
|
||||
|
@ -68,48 +79,39 @@ class document_page(osv.osv):
|
|||
'write_date': fields.datetime("Modification Date", select=True, readonly=True),
|
||||
'write_uid': fields.many2one('res.users', "Last Contributor", select=True, readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'type':'content',
|
||||
}
|
||||
|
||||
def onchange_parent_id(self, cr, uid, ids, parent_id, content, context=None):
|
||||
res = {}
|
||||
if parent_id and not content:
|
||||
parent = self.browse(cr, uid, parent_id, context=context)
|
||||
if parent.type == "category":
|
||||
res['value'] = {
|
||||
'content': parent.content,
|
||||
}
|
||||
return res
|
||||
|
||||
def create_history(self, cr, uid, ids, vals, context=None):
|
||||
for i in ids:
|
||||
history = self.pool.get('document.page.history')
|
||||
history = self.pool.get('blog.post.history')
|
||||
if vals.get('content'):
|
||||
res = {
|
||||
'content': vals.get('content', ''),
|
||||
'page_id': i,
|
||||
'post_id': i,
|
||||
}
|
||||
history.create(cr, uid, res)
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
page_id = super(document_page, self).create(cr, uid, vals, context)
|
||||
self.create_history(cr, uid, [page_id], vals, context)
|
||||
return page_id
|
||||
if context is None:
|
||||
context = {}
|
||||
create_context = dict(context, mail_create_nolog=True)
|
||||
post_id = super(BlogPost, self).create(cr, uid, vals, context=create_context)
|
||||
self.create_history(cr, uid, [post_id], vals, context)
|
||||
return post_id
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
result = super(document_page, self).write(cr, uid, ids, vals, context)
|
||||
result = super(BlogPost, self).write(cr, uid, ids, vals, context)
|
||||
self.create_history(cr, uid, ids, vals, context)
|
||||
return result
|
||||
|
||||
class document_page_history(osv.osv):
|
||||
_name = "document.page.history"
|
||||
|
||||
class BlogPostHistory(osv.Model):
|
||||
_name = "blog.post.history"
|
||||
_description = "Document Page History"
|
||||
_order = 'id DESC'
|
||||
_rec_name = "create_date"
|
||||
|
||||
_columns = {
|
||||
'page_id': fields.many2one('document.page', 'Page'),
|
||||
'post_id': fields.many2one('blog.post', 'Blog Post'),
|
||||
'summary': fields.char('Summary', size=256, select=True),
|
||||
'content': fields.text("Content"),
|
||||
'create_date': fields.datetime("Date"),
|
||||
|
|
|
@ -1,41 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
<record id="wiki_wiki_main" model="document.page">
|
||||
<field name="name">The OpenERP wiki</field>
|
||||
<field name="tags">help, quick start, wiki, formatting</field>
|
||||
<field name="minor_edit">0</field>
|
||||
<field name="index">1</field>
|
||||
<field name="summary">Initial Page</field>
|
||||
<field name="content">==The OpenERP wiki==
|
||||
<!-- <data noupdate="1"> -->
|
||||
<data>
|
||||
|
||||
[[File:http://www.openerp.com/sites/all/themes/openerp/logo.png OpenERP]]
|
||||
|
||||
The OpenERP wiki allows you to manage your enterprise's contents using wiki
|
||||
restructured texts. This module provides a collaborative way to manage internal
|
||||
FAQs, quality manuals, technical references, etc.
|
||||
|
||||
==Keypoints==
|
||||
* Same formating style than MediaWiki,
|
||||
* Any number of wiki group for different purposes,
|
||||
* Detailed history on all pages,
|
||||
* Integrated with the document management system.
|
||||
|
||||
==Why you should use the OpenERP integrated wiki than a separate wiki system ?==
|
||||
* Allows links to any document of the system,
|
||||
* Uses the access controls of OpenERP for uniq access rights management,
|
||||
* Use it to describe projects, tasks, products,
|
||||
* Integrated with customer portal to provide restricted external accesses,
|
||||
* Linked to users processes for quality manuals.
|
||||
|
||||
==To get more information==
|
||||
* [[Basic Wiki Editing]]
|
||||
* [[Wiki Documentation]]
|
||||
* [http://openerp.com The OpenERP website]
|
||||
|
||||
|
||||
</field>
|
||||
<field name="parent_id" ref="wiki_groups_wikiformatting0"/>
|
||||
<!-- Post-related subtypes for messaging / Chatter -->
|
||||
<record id="mt_blog_post_new" model="mail.message.subtype">
|
||||
<field name="name">New Post</field>
|
||||
<field name="res_model">blog.post</field>
|
||||
<field name="default" eval="True"/>
|
||||
<field name="description">New Post</field>
|
||||
</record>
|
||||
<record id="mt_blog_post_published" model="mail.message.subtype">
|
||||
<field name="name">Post Published</field>
|
||||
<field name="res_model">blog.post</field>
|
||||
<field name="default" eval="False"/>
|
||||
<field name="description">Post Published</field>
|
||||
</record>
|
||||
<!-- Project-related subtypes for messaging / Chatter -->
|
||||
<record id="mt_blog_category_post_new" model="mail.message.subtype">
|
||||
<field name="name">New Post</field>
|
||||
<field name="res_model">blog.category</field>
|
||||
<field name="default" eval="True"/>
|
||||
<field name="parent_id" eval="ref('mt_blog_post_new')"/>
|
||||
<field name="relation_field">category_id</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
<record id="base.user_demo" model="res.users">
|
||||
<field eval="[(4, ref('base.group_sale_salesman')),(4, ref('base.group_document_user'))]" name="groups_id"/>
|
||||
</record>
|
||||
<record id="demo_category1" model="document.page">
|
||||
<field name="name">OpenERP Features</field>
|
||||
<field name="type">category</field>
|
||||
<field name="content">
|
||||
<!-- <data noupdate="1"> -->
|
||||
<data>
|
||||
|
||||
<!-- CATEGORIES -->
|
||||
<record id="blog_category_1" model="blog.category">
|
||||
<field name="name">News</field>
|
||||
<field name="description">Presentation of new OpenERP features</field>
|
||||
<field name="template">
|
||||
Summary of the feature
|
||||
|
||||
Long explanation
|
||||
|
@ -15,13 +15,22 @@ Long explanation
|
|||
Conclusion
|
||||
|
||||
Additional ressources
|
||||
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="demo_page1" model="document.page">
|
||||
<field name="name">OpenERP 6.1. Functional Demo</field>
|
||||
<field name="parent_id" ref="demo_category1"/>
|
||||
<!-- TAGS -->
|
||||
<record id="blog_tag_1" model="blog.tag">
|
||||
<field name="name">functional</field>
|
||||
</record>
|
||||
<record id="blog_tag_2" model="blog.tag">
|
||||
<field name="name">pos</field>
|
||||
</record>
|
||||
|
||||
<!-- POSTS -->
|
||||
<record id="blog_post_1" model="blog.post">
|
||||
<field name="name">OpenERP 7.0 Functional Demo</field>
|
||||
<field name="category_id" ref="blog_category_1"/>
|
||||
<field name="tag_ids" eval="[(6, 0, [ref('blog_tag_1')])]"/>
|
||||
<field name="content">
|
||||
<![CDATA[
|
||||
<br>
|
||||
|
@ -48,9 +57,9 @@ company, with your clients and implement it now for your business.<br>
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record id="demo_page2" model="document.page">
|
||||
<record id="blog_post_2" model="blog.post">
|
||||
<field name="name">Personalise Dashboards</field>
|
||||
<field name="parent_id" ref="demo_category1"/>
|
||||
<field name="category_id" ref="blog_category_1"/>
|
||||
<field name="content">
|
||||
<![CDATA[
|
||||
<br>
|
||||
|
@ -89,9 +98,10 @@ you change your mind there is a reset button to return to the default view.<br>
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record id="demo_page3" model="document.page">
|
||||
<record id="blog_post_3" model="blog.post">
|
||||
<field name="name">Touchscreen Point of Sale</field>
|
||||
<field name="parent_id" ref="demo_category1"/>
|
||||
<field name="category_id" ref="blog_category_1"/>
|
||||
<field name="tag_ids" eval="[(6, 0, [ref('blog_tag_1'), ref('blog_tag_2')])]"/>
|
||||
<field name="content">
|
||||
<![CDATA[
|
||||
<br>
|
||||
|
|
|
@ -4,45 +4,62 @@
|
|||
<menuitem name="Knowledge" id="knowledge.menu_document"/>
|
||||
<menuitem name="Pages" id="menu_wiki" parent="knowledge.menu_document" sequence="20" />
|
||||
|
||||
<!-- wiki tree view -->
|
||||
<record id="view_wiki_tree_children" model="ir.ui.view">
|
||||
<field name="name">document.page.tree</field>
|
||||
<field name="model">document.page</field>
|
||||
<field name="field_parent">child_ids</field>
|
||||
<field name="priority">100</field>
|
||||
<!-- Category views -->
|
||||
<record model="ir.ui.view" id="view_blog_category_list">
|
||||
<field name="name">blog.category.list</field>
|
||||
<field name="model">blog.category</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Document Page">
|
||||
<tree string="Blog Categories">
|
||||
<field name="name"/>
|
||||
<field name="write_uid"/>
|
||||
<field name="write_date"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<!-- wiki list view -->
|
||||
<record id="view_wiki_tree" model="ir.ui.view">
|
||||
<field name="name">document.page.list</field>
|
||||
<field name="model">document.page</field>
|
||||
<record model="ir.ui.view" id="view_blog_category_form">
|
||||
<field name="name">blog.category.form</field>
|
||||
<field name="model">blog.category</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Document Page">
|
||||
<form string="Blog Category" version="7.0">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="parent_id"/>
|
||||
<field name="description"/>
|
||||
<field name="template" widget="html"/>
|
||||
</group>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
|
||||
<field name="message_ids" widget="mail_thread" options='{"thread_level": 1}' placeholder="Send a message to the group"/>
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- page list view -->
|
||||
<record model="ir.ui.view" id="view_blog_post_list">
|
||||
<field name="name">blog.post.list</field>
|
||||
<field name="model">blog.post</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Blog Posts">
|
||||
<field name="name"/>
|
||||
<field name="category_id"/>
|
||||
<field name="create_uid" invisible="1"/>
|
||||
<field name="write_uid"/>
|
||||
<field name="write_date"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<!-- wiki Form view -->
|
||||
<record id="view_wiki_form" model="ir.ui.view">
|
||||
<field name="name">document.page.form</field>
|
||||
<field name="model">document.page</field>
|
||||
<!-- page form view -->
|
||||
<record model="ir.ui.view" id="view_blog_post_form">
|
||||
<field name="name">blog.post.form</field>
|
||||
<field name="model">blog.post</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Document Page" version="7.0">
|
||||
<field name="type" invisible="1"/>
|
||||
<form string="Blog Post" version="7.0">
|
||||
<sheet>
|
||||
<h1><field name="name" placeholder="Name"/></h1>
|
||||
<field name="tag_ids" widget="many2many_tags"/>
|
||||
<group class="oe_edit_only">
|
||||
<group>
|
||||
<field name="parent_id" on_change="onchange_parent_id(parent_id,content)" string="Category"/>
|
||||
<field name="category_id" string="Category"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="write_uid" groups="base.group_no_one"/>
|
||||
|
@ -50,28 +67,28 @@
|
|||
<field name="menu_id" groups="base.group_no_one"/>
|
||||
</group>
|
||||
</group>
|
||||
<div class="oe_edit_only" attrs="{'invisible':[('type','=','content')]}">
|
||||
<label for="content" string="Template"/>
|
||||
that will be used as a content template for all new page of this category.
|
||||
</div>
|
||||
<field name="content" placeholder="e.g. Once upon a time..." class="oe_edit_only" widget="html"/>
|
||||
<div class="oe_document_page">
|
||||
<field name="display_content" widget="html" class="oe_view_only" options='{"safe": True}'/>
|
||||
<field name="content" placeholder="e.g. Once upon a time..." widget="html"/>
|
||||
</div>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
|
||||
<field name="message_ids" widget="mail_thread" options='{"thread_level": 1}' placeholder="Send a message to the group"/>
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<!-- page Search view -->
|
||||
<record id="view_wiki_filter" model="ir.ui.view">
|
||||
<field name="name">document.page.search</field>
|
||||
<field name="model">document.page</field>
|
||||
<!-- page search view -->
|
||||
<record model="ir.ui.view" id="view_blog_post_search">
|
||||
<field name="name">blog.post.search</field>
|
||||
<field name="model">blog.post</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Document Page">
|
||||
<search string="Blog Post">
|
||||
<field name="name" string="Content" filter_domain="['|', ('name','ilike',self), ('content','ilike',self)]"/>
|
||||
<field name="write_uid"/>
|
||||
<field name="parent_id"/>
|
||||
<field name="category_id"/>
|
||||
<group expand="0" string="Group By...">
|
||||
<filter string="Document Type" domain="[]" context="{'group_by':'parent_id'}"/>
|
||||
<filter string="Category" domain="[]" context="{'group_by': 'category_id'}"/>
|
||||
<filter string="Author" domain="[]" context="{'group_by': 'create_uid'}"/>
|
||||
<filter string="Last Contributor" domain="[]" context="{'group_by': 'write_uid'}"/>
|
||||
</group>
|
||||
|
@ -79,38 +96,33 @@
|
|||
</field>
|
||||
</record>
|
||||
<!-- page action -->
|
||||
<record id="action_page" model="ir.actions.act_window">
|
||||
<field name="name">Pages</field>
|
||||
<field name="res_model">document.page</field>
|
||||
<field name="domain">[('type','=','content')]</field>
|
||||
<field name="context">{'default_type': 'content'}</field>
|
||||
<record model="ir.actions.act_window" id="action_blog_post">
|
||||
<field name="name">Blog Posts</field>
|
||||
<field name="res_model">blog.post</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_wiki_tree"/>
|
||||
<field name="search_view_id" ref="view_wiki_filter"/>
|
||||
<field name="view_id" ref="view_blog_post_list"/>
|
||||
<field name="search_view_id" ref="view_blog_post_search"/>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
Click to create a new web page.
|
||||
Click to create a new blog post.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
<menuitem id="menu_page" parent="menu_wiki" name="Pages" action="action_page" sequence="10"/>
|
||||
<record id="action_category" model="ir.actions.act_window">
|
||||
<menuitem id="menu_page" parent="menu_wiki" name="Pages" action="action_blog_post" sequence="10"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_blog_category">
|
||||
<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="res_model">blog.category</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_wiki_tree"/>
|
||||
<field name="search_view_id" ref="view_wiki_filter"/>
|
||||
</record>
|
||||
<menuitem id="menu_category" parent="menu_wiki" name="Categories" action="action_category" sequence="20"/>
|
||||
<menuitem id="menu_category" parent="menu_wiki" name="Categories" action="action_blog_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>
|
||||
<record model="ir.ui.view" id="view_blog_history_tree">
|
||||
<field name="name">blog.post.history.tree</field>
|
||||
<field name="model">blog.post.history</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Document History">
|
||||
<field name="create_date"/>
|
||||
|
@ -120,11 +132,11 @@
|
|||
</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>
|
||||
<record model="ir.ui.view" id="view_blog_history_form">
|
||||
<field name="name">blog.post.history.form</field>
|
||||
<field name="model">blog.post.history</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Document Page History" version="7.0">
|
||||
<form string="Blog Post History" version="7.0">
|
||||
<label for="page_id" class="oe_edit_only"/>
|
||||
<h1><field name="page_id" select="1" /></h1>
|
||||
<label for="create_date" class="oe_edit_only"/>
|
||||
|
@ -137,7 +149,7 @@
|
|||
<!-- 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="res_model">blog.post.history</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
@ -147,16 +159,16 @@
|
|||
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
|
||||
res_model="blog.post.history"
|
||||
src_model="blog.post"/>
|
||||
<!-- <act_window
|
||||
id="action_related_page_create_menu"
|
||||
name="Create Menu"
|
||||
res_model="document.page.create.menu"
|
||||
res_model="blog.post.create.menu"
|
||||
target="new"
|
||||
view_type="form"
|
||||
view_mode="form"
|
||||
src_model="document.page"/>
|
||||
src_model="blog.post"/> -->
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="0">
|
||||
<record id="base.group_document_user" model="res.groups">
|
||||
<field name="users" eval="[(4, ref('base.user_root'))]"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
document_page_all,document.page,model_document_page,,1,0,0,0
|
||||
document_page,document.page,model_document_page,base.group_user,1,1,1,1
|
||||
document_page_history,document.page.history,model_document_page_history,base.group_user,1,0,1,0
|
||||
blog_post_all,blog.post,model_blog_post,,1,0,0,0
|
||||
blog_post,blog.post,model_blog_post,base.group_user,1,1,1,1
|
||||
blog_post_history,blog.post.history,model_blog_post_history,base.group_user,1,0,1,0
|
||||
|
|
|
|
@ -1,7 +1,3 @@
|
|||
.oe_form_editable .oe_document_page {
|
||||
display: none;
|
||||
}
|
||||
|
||||
table.diff {font-family:Courier; border:medium;}
|
||||
.diff_header {background-color:#e0e0e0}
|
||||
td.diff_header {text-align:right}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
-
|
||||
In order to test the document_page in OpenERP, I create a new page to category demo_category1
|
||||
In order to test the document_page in OpenERP, I create a new page to category blog_category_1
|
||||
-
|
||||
!record {model: document.page, id: test_page0}:
|
||||
name: Test Page0
|
||||
parent_id: demo_category1
|
||||
parent_id: blog_category_1
|
||||
content: 'Test content
|
||||
|
||||
The Open ERP wiki allows you to manage your enterprise contents using wiki
|
||||
|
@ -15,11 +15,11 @@
|
|||
-
|
||||
I check the category index contains my page.
|
||||
-
|
||||
!python {model: document.page}: |
|
||||
!python {model: blog.post}: |
|
||||
res = self.read(cr, uid, [ref('demo_category1')], ['display_content'])
|
||||
assert res[0]['display_content'].find('Test Page') > 1
|
||||
-
|
||||
!record {model: document.page, id: test_page0}:
|
||||
!record {model: blog.post, id: test_page0}:
|
||||
content: 'Test updated content
|
||||
|
||||
The Open ERP wiki allows you to manage your enterprise contents using wiki
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import document_page_create_menu
|
||||
# import document_page_create_menu
|
||||
import document_page_show_diff
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -21,17 +21,17 @@
|
|||
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
import base64
|
||||
|
||||
|
||||
class showdiff(osv.osv_memory):
|
||||
""" Disp[ay Difference for History """
|
||||
|
||||
_name = 'wizard.document.page.history.show_diff'
|
||||
_name = 'blog.post.history.show_diff'
|
||||
|
||||
def get_diff(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
history = self.pool.get('document.page.history')
|
||||
history = self.pool.get('blog.post.history')
|
||||
ids = context.get('active_ids', [])
|
||||
|
||||
diff = ""
|
||||
|
@ -43,7 +43,7 @@ class showdiff(osv.osv_memory):
|
|||
|
||||
elif len(ids) == 1:
|
||||
old = history.browse(cr, uid, ids[0])
|
||||
nids = history.search(cr, uid, [('page_id', '=', old.page_id.id)])
|
||||
nids = history.search(cr, uid, [('post_id', '=', old.post_id.id)])
|
||||
nids.sort()
|
||||
diff = history.getDiff(cr, uid, ids[0], nids[-1])
|
||||
else:
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<!-- Create Index Form view -->
|
||||
<record id="view_wiki_show_diff" model="ir.ui.view">
|
||||
<field name="name">Show Difference</field>
|
||||
<field name="model">wizard.document.page.history.show_diff</field>
|
||||
<field name="model">blog.post.history.show_diff</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Difference" version="7.0">
|
||||
<field name="diff" widget="html" options='{"safe": True}'/>
|
||||
|
@ -19,7 +19,7 @@
|
|||
<record id="action_view_wiki_show_diff" model="ir.actions.act_window">
|
||||
<field name="name">Difference</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">wizard.document.page.history.show_diff</field>
|
||||
<field name="res_model">blog.post.history.show_diff</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
|
@ -29,8 +29,8 @@
|
|||
id="action_view_wiki_show_diff_values"
|
||||
key2="client_action_multi"
|
||||
name="Difference"
|
||||
res_model="wizard.document.page.history.show_diff"
|
||||
src_model="document.page.history"
|
||||
res_model="blog.post.history.show_diff"
|
||||
src_model="blog.post.history"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
view_type="form"/>
|
||||
|
|
Loading…
Reference in New Issue