summaryrefslogtreecommitdiff
path: root/addons/website_forum_doc/models/documentation.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/website_forum_doc/models/documentation.py')
-rw-r--r--addons/website_forum_doc/models/documentation.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/addons/website_forum_doc/models/documentation.py b/addons/website_forum_doc/models/documentation.py
index 655040fb16f..6aea079cf71 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,21 @@ 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_default_stage_id(self, cr, uid, context=None):
+ stage_ids = self.pool["forum.documentation.stage"].search(cr, uid, [], limit=1, context=context)
+ return stage_ids and stage_ids[0] or False
+
+ _defaults = {
+ 'documentation_stage_id': _get_default_stage_id,
+ }
+
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 +84,3 @@ class Post(osv.Model):
_group_by_full = {
'documentation_stage_id': _read_group_stage_ids,
}
-