1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
23 from osv import fields
24 from tools.translate import _
27 VoteValues = [('-1', 'Not Voted'), ('0', 'Very Bad'), ('25', 'Bad'), \
28 ('50', 'Normal'), ('75', 'Good'), ('100', 'Very Good') ]
29 DefaultVoteValue = '50'
31 class idea_category(osv.osv):
32 """ Category of Idea """
33 _name = "idea.category"
34 _description = "Idea Category"
36 'name': fields.char('Category Name', size=64, required=True),
39 ('name', 'unique(name)', 'The name of the category must be unique' )
45 class idea_idea(osv.osv):
48 _inherit = ['mail.thread']
50 'create_uid': fields.many2one('res.users', 'Creator', required=True, readonly=True),
51 'name': fields.char('Idea Summary', size=64, required=True, readonly=True, oldname='title', states={'draft':[('readonly',False)]}),
52 'description': fields.text('Description', help='Content of the idea', readonly=True, states={'draft':[('readonly',False)]}),
53 'category_ids': fields.many2many('idea.category', string='Tags', readonly=True, states={'draft':[('readonly',False)]}),
54 'state': fields.selection([('draft', 'New'),
56 ('cancel', 'Refused'),
58 'Status', readonly=True
62 ('name', 'unique(name)', 'The name of the idea must be unique' )
65 'state': lambda *a: 'draft',
69 def idea_cancel(self, cr, uid, ids, context=None):
70 self.write(cr, uid, ids, { 'state': 'cancel' })
71 self.message_post(cr, uid, ids, body=_('Idea has been refused.'), context=context)
74 def idea_open(self, cr, uid, ids, context={}):
75 self.write(cr, uid, ids, {'state': 'open'}, context=context)
76 self.message_post(cr, uid, ids, body=_('Idea has been opened.'), context=context)
79 def idea_close(self, cr, uid, ids, context={}):
80 self.write(cr, uid, ids, {'state': 'close'}, context=context)
81 self.message_post(cr, uid, ids, body=_('Idea has been accepted.'), context=context)
84 def idea_draft(self, cr, uid, ids, context={}):
85 self.write(cr, uid, ids, {'state': 'draft'}, context=context)
86 self.message_post(cr, uid, ids, body=_('Idea has been created.'), context=context)