[CLEAN]: clean idea module according to the fabien review

bzr revid: mga@tinyerp.com-20100520183422-bu03cbpav8qe317z
This commit is contained in:
Mantavya Gajjar 2010-05-21 00:04:22 +05:30
parent 48bbaeb253
commit f8bf43dba6
2 changed files with 38 additions and 10 deletions

View File

@ -29,7 +29,7 @@ DefaultVoteValue = '50'
class idea_category(osv.osv):
""" Category of Idea """
_name = "idea.category"
_description = "Idea Category"
@ -38,7 +38,7 @@ class idea_category(osv.osv):
'summary': fields.text('Summary'),
'parent_id': fields.many2one('idea.category', 'Parent Categories', ondelete='set null'),
'child_ids': fields.one2many('idea.category', 'parent_id', 'Child Categories'),
'visibility':fields.boolean('Open Idea?', required=False),
'visibility':fields.boolean('Open Idea?', required=False, help="If True creator of the idea will be visible to others"),
}
_sql_constraints = [
('name', 'unique(parent_id,name)', 'The name of the category must be unique' )
@ -152,8 +152,8 @@ class idea_idea(osv.osv):
_columns = {
'user_id': fields.many2one('res.users', 'Creator', required=True, readonly=True),
'title': fields.char('Idea Summary', size=64, required=True),
'description': fields.text('Description', help='Content of the idea'),
'title': fields.char('Idea Summary', size=64, required=True, readonly=True, states={'draft':[('readonly',False)]}),
'description': fields.text('Description', help='Content of the idea', readonly=True, states={'draft':[('readonly',False)]}),
'comment_ids': fields.one2many('idea.comment', 'idea_id', 'Comments'),
'create_date': fields.datetime('Creation date', readonly=True),
'vote_ids': fields.one2many('idea.vote', 'idea_id', 'Vote'),
@ -161,7 +161,7 @@ class idea_idea(osv.osv):
'vote_avg': fields.function(_vote_avg_compute, method=True, string="Average Score", type="float"),
'count_votes': fields.function(_vote_count, method=True, string="Count of votes", type="integer"),
'count_comments': fields.function(_comment_count, method=True, string="Count of comments", type="integer"),
'category_id': fields.many2one('idea.category', 'Category', required=True),
'category_id': fields.many2one('idea.category', 'Category', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'state': fields.selection([('draft', 'Draft'),
('open', 'Opened'),
('close', 'Accepted'),
@ -203,8 +203,30 @@ class idea_idea(osv.osv):
vals.update({
'visibility':visibility
})
res_id = super(idea_idea, self).create(cr, user, vals, context)
return res_id
def copy(self, cr, uid, id, default={}, context={}):
"""
Create the new record in idea_idea model from existing one
@param cr: A database cursor
@param user: ID of the user currently logged in
@param id: list of record ids on which copy method executes
@param default: dict type contains the values to be overridden during copy of object
@param context: context arguments, like lang, time zone
@return: Returns the id of the new record
"""
default.update({
'comment_ids':False,
'vote_ids':False,
'stat_vote_ids':False
})
res_id = super(idea_idea, self).copy(cr, uid, id, default, context)
return res_id
def write(self, cr, user, ids, vals, context=None):
"""

View File

@ -133,22 +133,29 @@
<field name="arch" type="xml">
<form string="New Idea">
<group col="6" colspan="4">
<field name="title" colspan="4" select="1" />
<field name="title" select="1" />
<field name="category_id" select="1"/>
<field name="my_vote"/>
<field name="user_id" attrs="{'invisible':[('visibility','=',False)]}"/>
<field name="vote_avg" widget="progressbar"/>
<group col="4" colspan="2">
<field name="my_vote" readonly="1"/>
<button name="%(idea.action_idea_post_vote)d" icon="gtk-execute" states="open" type="action" string="Submit Vote"/>
</group>
</group>
<notebook colspan="4">
<page string="Idea Detail">
<field name="description" nolabel="1" colspan="4" widget="text_wiki"/>
</page>
<page string="Comments" groups="base.group_extended">
<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" />
</form>
<tree string="Comments">
<field name="create_date"/>
<field name="content"/>
</tree>
</field>
</page>
<page string="Vote" groups="base.group_extended">
@ -159,7 +166,7 @@
</tree>
</field>
</page>
<page string="Statistics">
<page string="Statistics" groups="base.group_extended">
<group col="6" colspan="4">
<field name="count_comments" />
<field name="count_votes" />
@ -179,7 +186,6 @@
<group colspan="4" col="6">
<field name="state"/>
<button name="idea_open" string="Open" states="draft" icon="gtk-go-forward"/>
<button name="%(idea.action_idea_post_vote)d" icon="gtk-execute" states="open" type="action" string="Submit Vote"/>
<button name="idea_close" string="Accept" states="open" icon="gtk-jump-to"/>
<button name="idea_cancel" string="Refuse" states="open" icon="gtk-cancel"/>