summaryrefslogtreecommitdiff
path: root/addons/website_forum_doc/models/forum_documentation_toc.py
diff options
context:
space:
mode:
authorSrushti Patel <shp@odoo.com>2015-09-09 16:46:45 +0530
committerDavid Monjoie <dmo@odoo.com>2016-04-08 13:54:06 +0200
commitb88060e5bae0d239a2b7879b9661d015ec9df3b9 (patch)
tree0b20112154cad37670f010b5edb5ad42de51a8cf /addons/website_forum_doc/models/forum_documentation_toc.py
parent4083f5460085d8663643344728f49cae31b720c0 (diff)
[MOV] website_forum_doc: split Documentation.py file
Diffstat (limited to 'addons/website_forum_doc/models/forum_documentation_toc.py')
-rw-r--r--addons/website_forum_doc/models/forum_documentation_toc.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/addons/website_forum_doc/models/forum_documentation_toc.py b/addons/website_forum_doc/models/forum_documentation_toc.py
new file mode 100644
index 00000000000..9f36c178c48
--- /dev/null
+++ b/addons/website_forum_doc/models/forum_documentation_toc.py
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+
+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)
+ res = []
+ for record in reads:
+ name = record['name']
+ if record['parent_id']:
+ name = record['parent_id'][1]+' / '+name
+ res.append((record['id'], name))
+ return res
+
+ # TODO master remove me
+ def _name_get_fnc(self, cr, uid, ids, prop, unknow_none, context=None):
+ res = self.name_get(cr, uid, ids, context=context)
+ return dict(res)
+
+ _columns = {
+ 'sequence': fields.integer('Sequence'),
+ 'name': fields.char('Name', required=True, translate=True),
+ 'introduction': fields.html('Introduction', translate=True),
+ 'parent_id': fields.many2one('forum.documentation.toc', 'Parent Table Of Content', ondelete='cascade'),
+ 'child_ids': fields.one2many('forum.documentation.toc', 'parent_id', 'Children Table Of Content'),
+ 'parent_left': fields.integer('Left Parent', select=True),
+ 'parent_right': fields.integer('Right Parent', select=True),
+ 'post_ids': fields.one2many('forum.post', 'documentation_toc_id', 'Posts'),
+ 'forum_id': fields.many2one('forum.forum', 'Forum', required=True),
+ }
+
+ _constraints = [
+ (osv.osv._check_recursion, 'Error ! You cannot create recursive categories.', ['parent_id'])
+ ]
+
+
+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),
+ }