[IMP]: idea: usability improvement in idea module and add some new functionality for user vote
bzr revid: atp@tinyerp.co.in-20100506121854-ujd17vefm02o3x6w
This commit is contained in:
parent
6ce3d0ebff
commit
fda05ce231
|
@ -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 """
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
<field name="name" select="1"/>
|
||||
<field name="parent_id" select="1"/>
|
||||
<newline/>
|
||||
<field name="summary" colspan="4"/>
|
||||
<separator string="Summary" colspan="4"/>
|
||||
<field name="summary" colspan="4" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -128,6 +129,27 @@
|
|||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Search view for Idea vote -->
|
||||
|
||||
<record model="ir.ui.view" id="view_idea_vote_search">
|
||||
<field name="name">idea.vote.search</field>
|
||||
<field name="model">idea.vote</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Ideas vote">
|
||||
<group col="10" colspan="4">
|
||||
<field name="idea_id" widget="selection"/>
|
||||
<field name="user_id" widget="selection"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="1" string="Group By..." colspan="14">
|
||||
<filter string="Idea" icon="terp-crm" domain="[]" context="{'group_by':'idea_id'}"/>
|
||||
<filter string="User" name="user" icon="terp-partner" domain="[]" context="{'group_by':'user_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- New Idea Form View -->
|
||||
|
||||
|
@ -141,9 +163,12 @@
|
|||
<page string="Idea">
|
||||
<field name="title" select="1" />
|
||||
<field name="category_id" select="1"/>
|
||||
<field name="date" />
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="vote_avg" />
|
||||
<field name="description" colspan="4" widget="text_wiki"/>
|
||||
<field name="vote_avg" widget="progressbar"/>
|
||||
<field name="vote_user"/>
|
||||
<separator string="Description" colspan="4"/>
|
||||
<field name="description" colspan="4" widget="text_wiki" nolabel="1"/>
|
||||
<field name="state"/>
|
||||
<group colspan="2" col="3">
|
||||
<button name="idea_open" string="Open" states="draft" icon="gtk-go-forward"/>
|
||||
|
@ -154,8 +179,9 @@
|
|||
<page string="Comments">
|
||||
<field name="comment_ids" nolabel="1" colspan="4">
|
||||
<form string="Comment">
|
||||
<separator string="Your comment" colspan="4"/>
|
||||
<field name="content" nolabel="1" />
|
||||
<field name="user_id" colspan="2"/>
|
||||
<separator string="User comment" colspan="4"/>
|
||||
<field name="content" nolabel="1" colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
|
@ -209,17 +235,25 @@
|
|||
<field name="arch" type="xml">
|
||||
<search string="Ideas">
|
||||
<group col="10" colspan="4">
|
||||
<filter icon="gtk-execute" string="My" domain="[('user_id','=',uid)]" help="My Ideas"/>
|
||||
<filter icon="terp-project" string="My" domain="[('user_id','=',uid)]" help="My Ideas"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="gtk-execute" string="Draft"
|
||||
<filter icon="terp-project" string="Draft"
|
||||
domain="[('state','=','draft')]" help="Draft Ideas" />
|
||||
<filter icon="gtk-execute" string="Open"
|
||||
<filter icon="terp-project" string="Open"
|
||||
domain="[('state','=','open')]" help="Open Ideas" />
|
||||
<separator orientation="vertical"/>
|
||||
<field name="title" select="1"/>
|
||||
<field name="category_id" select="1"/>
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="category_id" widget="selection"/>
|
||||
<field name="user_id" widget="selection"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="1" string="Group By..." colspan="14">
|
||||
<filter string="Category" icon="terp-crm" domain="[]" context="{'group_by':'category_id'}"/>
|
||||
<filter string="State" icon="terp-crm" domain="[]" context="{'group_by':'state'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Idea date" icon="terp-crm" domain="[]" context="{'group_by':'date'}"/>
|
||||
<filter string="User" name="user" icon="terp-partner" domain="[]" context="{'group_by':'user_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -327,6 +361,7 @@
|
|||
<field name="res_model">idea.vote</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="search_view_id" ref="view_idea_vote_search"/>
|
||||
</record>
|
||||
|
||||
<menuitem name="All Votes" parent="menu_ideas" id="menu_idea_vote" action="action_idea_vote"/>
|
||||
|
|
|
@ -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 {}
|
||||
|
||||
|
|
|
@ -13,8 +13,9 @@
|
|||
<group colspan="4" >
|
||||
<field name="vote"/>
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<separator string="" colspan="4"/>
|
||||
<group colspan="4" col="6">
|
||||
<label string="" colspan="2"/>
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-ok" name="do_vote" string="Post Vote" type="object"/>
|
||||
</group>
|
||||
|
@ -22,17 +23,6 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Post Idea for vote Action -->
|
||||
|
||||
<record id="action_idea_post_vote" model="ir.actions.act_window">
|
||||
<field name="name">Vote</field>
|
||||
<field name="res_model">idea.post.vote</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_idea_post_vote"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<!-- Post Idea for vote Action Window -->
|
||||
|
||||
<act_window id="action_idea_post_vote_values"
|
||||
|
|
Loading…
Reference in New Issue