diff --git a/addons/website_forum_doc/models/documentation.py b/addons/website_forum_doc/models/documentation.py index 655040fb16f..773ec465d94 100644 --- a/addons/website_forum_doc/models/documentation.py +++ b/addons/website_forum_doc/models/documentation.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -import openerp from openerp.osv import osv, fields + class Documentation(osv.Model): _name = 'forum.documentation.toc' _description = 'Documentation ToC' @@ -10,12 +10,13 @@ class Documentation(osv.Model): _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'] @@ -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), @@ -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) @@ -72,4 +83,3 @@ class Post(osv.Model): _group_by_full = { 'documentation_stage_id': _read_group_stage_ids, } - diff --git a/addons/website_forum_doc/views/doc.xml b/addons/website_forum_doc/views/doc.xml index 2e21f0bff73..e0730906c64 100644 --- a/addons/website_forum_doc/views/doc.xml +++ b/addons/website_forum_doc/views/doc.xml @@ -87,7 +87,16 @@ - + + forum.post.list.doc + forum.post + + + + + + +