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' )
44 class idea_idea(osv.osv):
47 _inherit = ['mail.thread']
49 'create_uid': fields.many2one('res.users', 'Creator', required=True, readonly=True),
50 'name': fields.char('Idea Summary', size=64, required=True, readonly=True, oldname='title', states={'draft':[('readonly',False)]}),
51 'description': fields.text('Description', help='Content of the idea', readonly=True, states={'draft':[('readonly',False)]}),
52 'category_ids': fields.many2many('idea.category', string='Tags', readonly=True, states={'draft':[('readonly',False)]}),
53 'state': fields.selection([('draft', 'New'),
55 ('cancel', 'Refused'),
57 'Status', readonly=True
61 ('name', 'unique(name)', 'The name of the idea must be unique' )
64 'state': lambda *a: 'draft',
68 def idea_cancel(self, cr, uid, ids, context={}):
69 self.write(cr, uid, ids, { 'state': 'cancel' })
70 self.message_append_note(cr, uid, ids, body=_('Idea canceled.'), context=context)
73 def idea_open(self, cr, uid, ids, context={}):
74 self.write(cr, uid, ids, { 'state': 'open'})
75 self.message_append_note(cr, uid, ids, body=_('Idea accepted.'), context=context)
78 def idea_close(self, cr, uid, ids, context={}):
79 self.message_append_note(cr, uid, ids, body=_('Idea done.'), context=context)
80 self.write(cr, uid, ids, { 'state': 'close' })
83 def idea_draft(self, cr, uid, ids, context={}):
84 self.message_append_note(cr, uid, ids, body=_('Idea reset to draft.'), context=context)
85 self.write(cr, uid, ids, { 'state': 'draft' })