game/addons/game_base/models/forum.py

35 lines
1.1 KiB
Python

from odoo import models, fields
class GameForumThread(models.Model):
_name = 'game.forum.thread'
_description = '论坛主题'
_rec_name = 'name'
_order = 'pinned desc, create_date desc'
CAT = [
('discuss', '综合讨论'),
('strategy', '攻略'),
('lore', '背景考据'),
('bug', '反馈'),
('showcase', '作品秀'),
]
name = fields.Char(string='标题', required=True)
category = fields.Selection(CAT, string='分类', default='discuss', index=True)
author_name = fields.Char(string='作者')
body_html = fields.Html(string='正文')
pinned = fields.Boolean(string='置顶', default=False)
post_ids = fields.One2many('game.forum.post', 'thread_id', string='回复')
class GameForumPost(models.Model):
_name = 'game.forum.post'
_description = '论坛回复'
_rec_name = 'author_name'
_order = 'create_date asc'
thread_id = fields.Many2one('game.forum.thread', string='主题', ondelete='cascade', required=True)
author_name = fields.Char(string='作者')
body_html = fields.Html(string='内容')