summaryrefslogtreecommitdiff
path: root/addons/website_forum_doc/models
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2014-09-03 10:15:06 +0200
committerThibault Delavallée <tde@openerp.com>2014-09-03 10:39:30 +0200
commit04d95c6a1a6d2cbb69e3bc3d9dd7f2da06d945ec (patch)
tree03ff96a59f376ee7cc749538d4610f68189d6167 /addons/website_forum_doc/models
parent78fa86193612e6831453bba003a8045a7d3b7c6c (diff)
[FIX] website_forum_doc: default stage for post + removed unused import + added toc_id field in post tree view
Diffstat (limited to 'addons/website_forum_doc/models')
-rw-r--r--addons/website_forum_doc/models/documentation.py16
1 files changed, 13 insertions, 3 deletions
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,
}
-