Launchpad automatic translations update.
[odoo/odoo.git] / addons / idea / idea.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
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.
11 #
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.
16 #
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/>.
19 #
20 ##############################################################################
21
22 from openerp.osv import osv
23 from openerp.osv import fields
24 from openerp.tools.translate import _
25 import time
26
27 VoteValues = [('-1', 'Not Voted'), ('0', 'Very Bad'), ('25', 'Bad'), \
28               ('50', 'Normal'), ('75', 'Good'), ('100', 'Very Good') ]
29 DefaultVoteValue = '50'
30
31 class idea_category(osv.osv):
32     """ Category of Idea """
33     _name = "idea.category"
34     _description = "Idea Category"
35     _columns = {
36         'name': fields.char('Category Name', size=64, required=True),
37     }
38     _sql_constraints = [
39         ('name', 'unique(name)', 'The name of the category must be unique')
40     ]
41     _order = 'name asc'
42
43
44 class idea_idea(osv.osv):
45     """ Idea """
46     _name = 'idea.idea'
47     _inherit = ['mail.thread']
48     _columns = {
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'),
54             ('open', 'Accepted'),
55             ('cancel', 'Refused'),
56             ('close', 'Done')],
57             'Status', readonly=True, track_visibility='onchange',
58         )
59     }
60     _sql_constraints = [
61         ('name', 'unique(name)', 'The name of the idea must be unique')
62     ]
63     _defaults = {
64         'state': lambda *a: 'draft',
65     }
66     _order = 'name asc'
67
68     def idea_cancel(self, cr, uid, ids, context=None):
69         return self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
70
71     def idea_open(self, cr, uid, ids, context={}):
72         return self.write(cr, uid, ids, {'state': 'open'}, context=context)
73
74     def idea_close(self, cr, uid, ids, context={}):
75         return self.write(cr, uid, ids, {'state': 'close'}, context=context)
76
77     def idea_draft(self, cr, uid, ids, context={}):
78         return self.write(cr, uid, ids, {'state': 'draft'}, context=context)