diff --git a/addons/idea/idea.py b/addons/idea/idea.py
index e698c85d0b4..37bdaa80b7f 100644
--- a/addons/idea/idea.py
+++ b/addons/idea/idea.py
@@ -148,7 +148,6 @@ class idea_idea(osv.osv):
if int(field_value) >= 0:
vote_obj.create(cr, uid, {'idea_id': id, 'user_id': uid, 'score': textual_value })
-
_columns = {
'user_id': fields.many2one('res.users', 'Creator', required=True, readonly=True),
'title': fields.char('Idea Summary', size=64, required=True),
@@ -170,12 +169,16 @@ class idea_idea(osv.osv):
opened by the user, the state is \'Opened\'.\
\nIf the idea is accepted, the state is \'Accepted\'.'),
'stat_vote_ids': fields.one2many('idea.vote.stat', 'idea_id', 'Statistics', readonly=True),
+ 'date': fields.date('Creation date'),
+ 'vote_user': fields.integer('Maximum Vote per User',
+ help="Set to one if you require only one Vote per user"),
}
_defaults = {
'user_id': lambda self,cr,uid,context: uid,
'my_vote': lambda *a: '-1',
- 'state': lambda *a: 'draft'
+ 'state': lambda *a: 'draft',
+ 'vote_user': lambda * a: 1,
}
_order = 'id desc'
@@ -196,7 +199,6 @@ class idea_idea(osv.osv):
return True
idea_idea()
-
class idea_comment(osv.osv):
""" Apply Idea for Comment """
@@ -210,7 +212,7 @@ class idea_comment(osv.osv):
'content': fields.text('Comment', required=True),
'create_date': fields.datetime('Creation date', readonly=True),
}
-
+
_defaults = {
'user_id': lambda self, cr, uid, context: uid
}
@@ -230,7 +232,7 @@ class idea_vote(osv.osv):
_columns = {
'user_id': fields.many2one('res.users', 'User'),
'idea_id': fields.many2one('idea.idea', 'Idea', required=True, ondelete='cascade'),
- 'score': fields.selection(VoteValues, 'Score', required=True)
+ 'score': fields.selection(VoteValues, 'Score', required=True),
}
_defaults = {
'score': lambda *a: DefaultVoteValue,
@@ -238,7 +240,6 @@ class idea_vote(osv.osv):
idea_vote()
-
class idea_vote_stat(osv.osv):
""" Idea votes Statistics """
diff --git a/addons/idea/idea_view.xml b/addons/idea/idea_view.xml
index 7dc0b5f7178..c1c94ec4bcf 100644
--- a/addons/idea/idea_view.xml
+++ b/addons/idea/idea_view.xml
@@ -14,7 +14,8 @@
-
+
+
@@ -128,6 +129,27 @@
+
+
+
+
+ idea.vote.search
+ idea.vote
+ search
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -141,9 +163,12 @@
+
-
-
+
+
+
+
@@ -154,8 +179,9 @@
@@ -209,17 +235,25 @@
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -327,6 +361,7 @@
idea.vote
form
tree,form
+
diff --git a/addons/idea/wizard/idea_post_vote.py b/addons/idea/wizard/idea_post_vote.py
index c5e6c530334..1da9a92e35a 100644
--- a/addons/idea/wizard/idea_post_vote.py
+++ b/addons/idea/wizard/idea_post_vote.py
@@ -34,7 +34,8 @@ class idea_post_vote(osv.osv_memory):
('25', 'Bad'),
('50', 'Normal'),
('75', 'Good'),
- ('100', 'Very Good') ], 'Post Vote', required=True)
+ ('100', 'Very Good') ], 'Post Vote', required=True),
+# 'content': fields.text('Comment'),
}
def view_init(self, cr, uid, fields, context=None):
@@ -47,7 +48,7 @@ class idea_post_vote(osv.osv_memory):
@param context: A standard dictionary for contextual values
"""
idea_obj = self.pool.get('idea.idea')
-
+
for idea in idea_obj.browse(cr, uid, context.get('active_ids', [])):
if idea.state in ['draft', 'close', 'cancel']:
raise osv.except_osv(_("Warning !"), _("Draft/Accepted/Cancelled \
@@ -57,7 +58,6 @@ ideas Could not be voted"))
\'Open\' state before vote for that idea.'))
return False
-
def do_vote(self, cr, uid, ids, context):
"""
@@ -67,14 +67,23 @@ ideas Could not be voted"))
@param ids: List of Idea Post vote’s IDs.
@return: Dictionary {}
"""
-
+
data = context and context.get('active_id', False) or False
vote_obj = self.pool.get('idea.vote')
-
+ comment_obj = self.pool.get('idea.comment')
+ idea_obj = self.pool.get('idea.idea')
for do_vote_obj in self.read(cr, uid, ids):
score = str(do_vote_obj['vote'])
- dic = {'idea_id': data, 'user_id': uid, 'score': score }
-
+# comment = do_vote_obj['content']
+ idea = idea_obj.browse(cr, uid, data)
+ user_limit = idea.vote_user
+ dic = {'idea_id': data, 'user_id': uid, 'score': score}
+# dic = {'idea_id': data, 'user_id': uid, 'score': score, 'content': comment}
+ cr.execute('select count(id) from idea_vote where user_id=%s\
+ and idea_id=%s' % (uid, context.get('active_id')))
+ res = cr.fetchone()[0]
+ if res >= user_limit:
+ raise osv.except_osv(_('Warning !'),_("You can not give Vote for this idea more than %s times") % (user_limit))
vote = vote_obj.create(cr, uid, dic)
return {}
diff --git a/addons/idea/wizard/idea_post_vote_view.xml b/addons/idea/wizard/idea_post_vote_view.xml
index e49e91f5661..d197497afce 100644
--- a/addons/idea/wizard/idea_post_vote_view.xml
+++ b/addons/idea/wizard/idea_post_vote_view.xml
@@ -13,8 +13,9 @@
-
+
+
@@ -22,17 +23,6 @@
-
-
-
- Vote
- idea.post.vote
- form
- tree,form
-
- new
-
-