Skip to content

Commit

Permalink
[FIX] website_forum_doc: default stage for post + removed unused impo…
Browse files Browse the repository at this point in the history
…rt + added toc_id field in post tree view
  • Loading branch information
tde-banana-odoo committed Sep 3, 2014
1 parent 78fa861 commit 04d95c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
16 changes: 13 additions & 3 deletions addons/website_forum_doc/models/documentation.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# -*- coding: utf-8 -*-

import openerp
from openerp.osv import osv, fields


class Documentation(osv.Model):
_name = 'forum.documentation.toc'
_description = 'Documentation ToC'
_inherit = ['website.seo.metadata']
_order = "parent_left"
_parent_order = "sequence, name"
_parent_store = True

def name_get(self, cr, uid, ids, context=None):
if isinstance(ids, (list, tuple)) and not len(ids):
return []
if isinstance(ids, (long, int)):
ids = [ids]
reads = self.read(cr, uid, ids, ['name','parent_id'], context=context)
reads = self.read(cr, uid, ids, ['name', 'parent_id'], context=context)
res = []
for record in reads:
name = record['name']
Expand Down Expand Up @@ -50,6 +51,7 @@ class DocumentationStage(osv.Model):
_name = 'forum.documentation.stage'
_description = 'Post Stage'
_order = 'sequence'

_columns = {
'sequence': fields.integer('Sequence'),
'name': fields.char('Stage Name', required=True, translate=True),
Expand All @@ -58,11 +60,20 @@ class DocumentationStage(osv.Model):

class Post(osv.Model):
_inherit = 'forum.post'

_columns = {
'documentation_toc_id': fields.many2one('forum.documentation.toc', 'Documentation ToC', ondelete='set null'),
'documentation_stage_id': fields.many2one('forum.documentation.stage', 'Documentation Stage'),
'color': fields.integer('Color Index')
}

def _get_documentation_stage(self, cr, uid, context=None):
return self.pool["forum.documentation.stage"].search(cr, uid, [], limit=1, context=context) or False

_defaults = {
'documentation_stage_id': _get_documentation_stage,
}

def _read_group_stage_ids(self, cr, uid, ids, domain, read_group_order=None, access_rights_uid=None, context=None):
stage_obj = self.pool.get('forum.documentation.stage')
stage_ids = stage_obj.search(cr, uid, [], context=context)
Expand All @@ -72,4 +83,3 @@ def _read_group_stage_ids(self, cr, uid, ids, domain, read_group_order=None, acc
_group_by_full = {
'documentation_stage_id': _read_group_stage_ids,
}

11 changes: 10 additions & 1 deletion addons/website_forum_doc/views/doc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,16 @@
</field>
</record>


<record id="view_forum_post_doc_list" model="ir.ui.view">
<field name="name">forum.post.list.doc</field>
<field name="model">forum.post</field>
<field name="inherit_id" ref="website_forum.view_forum_post_list"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='forum_id']" position="after">
<field name="documentation_toc_id"/>
</xpath>
</field>
</record>

</data>
</openerp>

0 comments on commit 04d95c6

Please sign in to comment.