document_page ready
bzr revid: al@openerp.com-20120810225046-qs3liea2s76lh6v0
This commit is contained in:
parent
4fb193140b
commit
4e4a7dcbee
|
@ -36,13 +36,13 @@ class document_page(osv.osv):
|
|||
if index:
|
||||
r = "<ul>" + "".join(index) + "</ul>"
|
||||
else:
|
||||
r = page.name
|
||||
r = '<a href="#id=%s">%s</a>'%(page.id,page.name)
|
||||
return r
|
||||
|
||||
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 == "index":
|
||||
if page.type == "category":
|
||||
content = self._get_page_index(cr, uid, page)
|
||||
else:
|
||||
content = page.content
|
||||
|
@ -51,9 +51,9 @@ class document_page(osv.osv):
|
|||
|
||||
_columns = {
|
||||
'name': fields.char('Title', required=True),
|
||||
'type':fields.selection([('content','Content'), ('index','Section')], 'Type', help="Page type"),
|
||||
'type':fields.selection([('content','Content'), ('category','Category')], 'Type', help="Page type"),
|
||||
|
||||
'parent_id': fields.many2one('document.page', 'Section', domain=[('type','=','index')]),
|
||||
'parent_id': fields.many2one('document.page', 'Category', domain=[('type','=','category')]),
|
||||
'child_ids': fields.one2many('document.page', 'parent_id', 'Children'),
|
||||
|
||||
'content': fields.text("Content"),
|
||||
|
@ -75,7 +75,7 @@ class document_page(osv.osv):
|
|||
res = {}
|
||||
if parent_id and not content:
|
||||
parent = self.browse(cr, uid, parent_id, context=context)
|
||||
if parent.type == "index":
|
||||
if parent.type == "category":
|
||||
res['value'] = {
|
||||
'content': parent.content,
|
||||
}
|
||||
|
|
|
@ -40,18 +40,14 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Document Page" version="7.0">
|
||||
<div class="oe_right oe_button_box">
|
||||
<button name="%(document_page.action_wiki_create_menu)d" string="Create Menu" type="action" class="oe_edit_only"/>
|
||||
<button name="%(document_page.action_wiki_create_menu)d" string="History" type="action" class="oe_edit_only"/>
|
||||
</div>
|
||||
<div class="oe_title">
|
||||
<label for="name" class="oe_edit_only"/>
|
||||
<h1><field name="name" select="1" /></h1>
|
||||
<h1><field name="name"/></h1>
|
||||
<field name="type" invisible="1"/>
|
||||
</div>
|
||||
<group class="oe_edit_only">
|
||||
<group>
|
||||
<field name="parent_id" on_change="onchange_parent_id(parent_id,content)" string="Section"/>
|
||||
<field name="type"/>
|
||||
<field name="parent_id" on_change="onchange_parent_id(parent_id,content)" string="Category"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="write_uid" groups="base.group_no_one"/>
|
||||
|
@ -64,7 +60,7 @@
|
|||
This will be used as template content for all new page of this section.
|
||||
</div>
|
||||
<field name="content" placeholder="e.g. Once upon a time..." class="oe_edit_only"/>
|
||||
<field name="display_content" widget="html"/>
|
||||
<field name="display_content" widget="html" class="oe_view_only"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -87,16 +83,29 @@
|
|||
</field>
|
||||
</record>
|
||||
<!-- page 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_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="10"/>
|
||||
<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>
|
||||
<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="help">Create web pages</field>
|
||||
</record>
|
||||
<menuitem parent="menu_wiki" id="menu_page" name="Pages" action="action_page"/>
|
||||
<menuitem id="menu_page" parent="menu_wiki" name="Pages" action="action_page" sequence="20"/>
|
||||
|
||||
<!-- History Tree view -->
|
||||
<record model="ir.ui.view" id="view_wiki_history_tree">
|
||||
|
@ -134,13 +143,22 @@
|
|||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem parent="menu_wiki" id="menu_page_history" name="Pages history" action="action_history" groups="base.group_no_one"/>
|
||||
<act_window
|
||||
id="act_wiki_wiki_history"
|
||||
<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
|
||||
id="action_related_page_create_menu"
|
||||
name="Create Menu"
|
||||
res_model="document.page.create.menu"
|
||||
target="new"
|
||||
view_type="form"
|
||||
view_mode="form"
|
||||
src_model="document.page"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -27,9 +27,20 @@ class document_page_create_menu(osv.osv_memory):
|
|||
_description = "Wizard Create Menu"
|
||||
|
||||
_columns = {
|
||||
'menu_name': fields.char('Menu Name', size=256, required=True),
|
||||
'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
|
||||
}
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
res = super(document_page_create_menu,self).default_get(cr, uid, fields, context=context)
|
||||
page_id = context.get('active_id')
|
||||
obj_page = self.pool.get('document.page')
|
||||
page = obj_page.browse(cr, uid, page_id, context=context)
|
||||
res['menu_name'] = page.name
|
||||
return res
|
||||
|
||||
def document_page_menu_create(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
@ -38,8 +49,7 @@ class document_page_create_menu(osv.osv_memory):
|
|||
obj_menu = self.pool.get('ir.ui.menu')
|
||||
obj_action = self.pool.get('ir.actions.act_window')
|
||||
page_id = context.get('active_id', False)
|
||||
if not page_id:
|
||||
return {}
|
||||
page = obj_page.browse(cr, uid, page_id, context=context)
|
||||
|
||||
datas = self.browse(cr, uid, ids, context=context)
|
||||
data = False
|
||||
|
@ -57,13 +67,12 @@ class document_page_create_menu(osv.osv_memory):
|
|||
'target': 'inline',
|
||||
'nodestroy': True,
|
||||
}
|
||||
page = obj_page.browse(cr, uid, page_id, context=context)
|
||||
value['domain'] = "[('parent_id','=',%d)]" % (page.id)
|
||||
value['res_id'] = page.id
|
||||
|
||||
action_id = obj_action.create(cr, uid, value)
|
||||
menu_id = obj_menu.create(cr, uid, {
|
||||
'name': page.name,
|
||||
'name': data.menu_name,
|
||||
'parent_id':data.menu_parent_id.id,
|
||||
'icon': 'STOCK_DIALOG_QUESTION',
|
||||
'action': 'ir.actions.act_window,'+ str(action_id),
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Create Menu" version="7.0">
|
||||
<group string="Menu Information">
|
||||
<field name="menu_name" />
|
||||
<field name="menu_parent_id" />
|
||||
</group>
|
||||
<footer>
|
||||
|
|
Loading…
Reference in New Issue