[REVIEW]: review idea module make it clean
[IMP]: implement new features for the same module bzr revid: mga@tinyerp.com-20100505144541-1taaprsq35d83sak
This commit is contained in:
@@ -42,7 +42,9 @@
|
||||
'security/idea_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'demo_xml': [],
|
||||
'demo_xml': [
|
||||
"idea_data.xml"
|
||||
],
|
||||
'installable': True,
|
||||
'certificate': '0071515601309',
|
||||
}
|
||||
|
||||
+77
-28
@@ -19,7 +19,9 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
from osv import osv
|
||||
from osv import fields
|
||||
from tools.translate import _
|
||||
|
||||
VoteValues = [('-1', 'Not Voted'), ('0', 'Very Bad'), ('25', 'Bad'), \
|
||||
('50', 'Normal'), ('75', 'Good'), ('100', 'Very Good') ]
|
||||
@@ -35,7 +37,8 @@ class idea_category(osv.osv):
|
||||
'name': fields.char('Category', size=64, required=True),
|
||||
'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')
|
||||
'child_ids': fields.one2many('idea.category', 'parent_id', 'Child Categories'),
|
||||
'visibility':fields.boolean('Open Idea?', required=False),
|
||||
}
|
||||
_sql_constraints = [
|
||||
('name', 'unique(parent_id,name)', 'The name of the category must be unique' )
|
||||
@@ -44,7 +47,6 @@ class idea_category(osv.osv):
|
||||
|
||||
idea_category()
|
||||
|
||||
|
||||
class idea_idea(osv.osv):
|
||||
""" Idea """
|
||||
_name = 'idea.idea'
|
||||
@@ -62,10 +64,10 @@ class idea_idea(osv.osv):
|
||||
return {}
|
||||
|
||||
sql = """SELECT i.id, avg(v.score::integer)
|
||||
FROM idea_idea i LEFT OUTER JOIN idea_vote v ON i.id = v.idea_id
|
||||
WHERE i.id = ANY(%s)
|
||||
GROUP BY i.id
|
||||
"""
|
||||
FROM idea_idea i LEFT OUTER JOIN idea_vote v ON i.id = v.idea_id
|
||||
WHERE i.id = ANY(%s)
|
||||
GROUP BY i.id
|
||||
"""
|
||||
|
||||
cr.execute(sql, (ids,))
|
||||
return dict(cr.fetchall())
|
||||
@@ -82,10 +84,10 @@ class idea_idea(osv.osv):
|
||||
return {}
|
||||
|
||||
sql = """SELECT i.id, COUNT(1)
|
||||
FROM idea_idea i LEFT OUTER JOIN idea_vote v ON i.id = v.idea_id
|
||||
WHERE i.id = ANY(%s)
|
||||
GROUP BY i.id
|
||||
"""
|
||||
FROM idea_idea i LEFT OUTER JOIN idea_vote v ON i.id = v.idea_id
|
||||
WHERE i.id = ANY(%s)
|
||||
GROUP BY i.id
|
||||
"""
|
||||
|
||||
cr.execute(sql, (ids,))
|
||||
return dict(cr.fetchall())
|
||||
@@ -102,10 +104,10 @@ class idea_idea(osv.osv):
|
||||
return {}
|
||||
|
||||
sql = """SELECT i.id, COUNT(1)
|
||||
FROM idea_idea i LEFT OUTER JOIN idea_comment c ON i.id = c.idea_id
|
||||
WHERE i.id = ANY(%s)
|
||||
GROUP BY i.id
|
||||
"""
|
||||
FROM idea_idea i LEFT OUTER JOIN idea_comment c ON i.id = c.idea_id
|
||||
WHERE i.id = ANY(%s)
|
||||
GROUP BY i.id
|
||||
"""
|
||||
|
||||
cr.execute(sql, (ids,))
|
||||
return dict(cr.fetchall())
|
||||
@@ -156,29 +158,77 @@ class idea_idea(osv.osv):
|
||||
'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'),
|
||||
'my_vote': fields.function(_vote_read, fnct_inv = _vote_save, \
|
||||
string="My Vote", method=True, type="selection", selection=VoteValues),
|
||||
'my_vote': fields.function(_vote_read, fnct_inv = _vote_save, string="My Vote", method=True, type="selection", selection=VoteValues),
|
||||
'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"),
|
||||
'count_comments': fields.function(_comment_count, method=True, string="Count of comments", type="integer"),
|
||||
'category_id': fields.many2one('idea.category', 'Category', required=True),
|
||||
'state': fields.selection([('draft', 'Draft'), ('open', 'Opened'), \
|
||||
('close', 'Accepted'), ('cancel', 'Cancelled')], \
|
||||
'State', readonly=True,
|
||||
help='When the Idea is created the state is \'Draft\'.\n It is \
|
||||
opened by the user, the state is \'Opened\'.\
|
||||
\nIf the idea is accepted, the state is \'Accepted\'.'),
|
||||
'state': fields.selection([('draft', 'Draft'),
|
||||
('open', 'Opened'),
|
||||
('close', 'Accepted'),
|
||||
('cancel', 'Cancelled')],
|
||||
'State', readonly=True,
|
||||
help='When the Idea is created the state is \'Draft\'.\n It is \
|
||||
opened by the user, the state is \'Opened\'.\
|
||||
\nIf the idea is accepted, the state is \'Accepted\'.'
|
||||
),
|
||||
'visibility':fields.boolean('Open Idea?', required=False),
|
||||
'stat_vote_ids': fields.one2many('idea.vote.stat', 'idea_id', 'Statistics', readonly=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'user_id': lambda self,cr,uid,context: uid,
|
||||
'my_vote': lambda *a: '-1',
|
||||
'state': lambda *a: 'draft'
|
||||
'state': lambda *a: 'draft',
|
||||
'visibility': lambda *a: True,
|
||||
}
|
||||
_order = 'id desc'
|
||||
|
||||
def create(self, cr, user, vals, context={}):
|
||||
"""
|
||||
Create a new record for a model idea_idea
|
||||
@param cr: A database cursor
|
||||
@param user: ID of the user currently logged in
|
||||
@param vals: provides data for new record
|
||||
@param context: context arguments, like lang, time zone
|
||||
|
||||
@return: Returns an id of the new record
|
||||
"""
|
||||
visibility = False
|
||||
|
||||
if vals.get('category_id', False):
|
||||
category_pool = self.pool.get('idea.category')
|
||||
category = category_pool.browse(cr, user, vals.get('category_id'), context)
|
||||
visibility = category.visibility
|
||||
|
||||
vals.update({
|
||||
'visibility':visibility
|
||||
})
|
||||
res_id = super(idea_idea, self).create(cr, user, vals, context)
|
||||
return res_id
|
||||
|
||||
def write(self, cr, user, ids, vals, context=None):
|
||||
"""
|
||||
Update redord(s) exist in {ids}, with new value provided in {vals}
|
||||
|
||||
@param cr: A database cursor
|
||||
@param user: ID of the user currently logged in
|
||||
@param ids: list of record ids to update
|
||||
@param vals: dict of new values to be set
|
||||
@param context: context arguments, like lang, time zone
|
||||
|
||||
@return: Returns True on success, False otherwise
|
||||
"""
|
||||
|
||||
state = self.browse(cr, user, ids[0]).state
|
||||
|
||||
if vals.get('my_vote', False):
|
||||
if vals.get('state', state) != 'open':
|
||||
raise osv.except_osv(_("Warning !"), _("Draft/Accepted/Cancelled ideas Could not be voted"))
|
||||
|
||||
res = super(idea_idea, self).write(cr, user, ids, vals, context)
|
||||
return res
|
||||
|
||||
def idea_cancel(self, cr, uid, ids):
|
||||
self.write(cr, uid, ids, { 'state': 'cancel' })
|
||||
return True
|
||||
@@ -190,7 +240,7 @@ class idea_idea(osv.osv):
|
||||
def idea_close(self, cr, uid, ids):
|
||||
self.write(cr, uid, ids, { 'state': 'close' })
|
||||
return True
|
||||
|
||||
|
||||
def idea_draft(self, cr, uid, ids):
|
||||
self.write(cr, uid, ids, { 'state': 'draft' })
|
||||
return True
|
||||
@@ -238,7 +288,6 @@ class idea_vote(osv.osv):
|
||||
|
||||
idea_vote()
|
||||
|
||||
|
||||
class idea_vote_stat(osv.osv):
|
||||
""" Idea votes Statistics """
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record model="idea.category" id="idea_category_general">
|
||||
<field name="name">General</field>
|
||||
<field name="summary">General Ideas</field>
|
||||
<field name="visibility">True</field>
|
||||
</record>
|
||||
|
||||
<record model="idea.idea" id="idea_idea_one">
|
||||
<field name="title">TODO: Need to put a good idea on OpenERP</field>
|
||||
<field name="description">TODO: Need to put a good idea on OpenERP</field>
|
||||
<field name="category_id" ref="idea_category_general"/>
|
||||
<field name="visibility">True</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
+73
-62
@@ -2,8 +2,7 @@
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Idea Category Form View -->
|
||||
|
||||
<!-- Idea Category Form View -->
|
||||
<menuitem name="Tools" id="base.menu_tools" icon="STOCK_PREFERENCES" sequence="15"/>
|
||||
<record model="ir.ui.view" id="view_idea_category_form">
|
||||
<field name="name">idea.category.form</field>
|
||||
@@ -11,16 +10,18 @@
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Category of ideas">
|
||||
<field name="name" select="1"/>
|
||||
<field name="parent_id" select="1"/>
|
||||
<newline/>
|
||||
<field name="summary" colspan="4"/>
|
||||
<group col="6" colspan="4">
|
||||
<field name="name" select="1"/>
|
||||
<field name="parent_id" select="1"/>
|
||||
<field name="visibility"/>
|
||||
</group>
|
||||
<separator string="Description" colspan="4"/>
|
||||
<field name="summary" colspan="4" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Idea Category Tree View -->
|
||||
|
||||
<!-- Idea Category Tree View -->
|
||||
<record model="ir.ui.view" id="view_idea_category_tree">
|
||||
<field name="name">idea.category.tree</field>
|
||||
<field name="model">idea.category</field>
|
||||
@@ -33,7 +34,7 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Idea Category Action -->
|
||||
<!-- Idea Category Action -->
|
||||
|
||||
<record model="ir.actions.act_window" id="action_idea_category">
|
||||
<field name="name">Categories</field>
|
||||
@@ -47,8 +48,7 @@
|
||||
|
||||
<menuitem name="Ideas" parent="base.menu_lunch_survey_root" id="menu_ideas"/>
|
||||
|
||||
<menuitem name="Categories" parent="menu_ideas"
|
||||
id="menu_idea_category" action="action_idea_category" />
|
||||
<menuitem name="Categories" parent="menu_ideas" id="menu_idea_category" action="action_idea_category" />
|
||||
|
||||
<!-- Idea Category Action -->
|
||||
|
||||
@@ -61,11 +61,6 @@
|
||||
|
||||
<menuitem name="Ideas" parent="base.menu_tools" id="menu_ideas1" sequence="4"/>
|
||||
|
||||
<menuitem
|
||||
name="Ideas by Categories" parent="menu_ideas1"
|
||||
id="menu_idea_category_tree"
|
||||
action="action_idea_category_tree"/>
|
||||
|
||||
<!-- Oepn Ideas Action -->
|
||||
|
||||
<record model="ir.actions.act_window" id="action_idea_idea_categ_open">
|
||||
@@ -137,21 +132,18 @@
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="New Idea">
|
||||
<notebook>
|
||||
<page string="Idea">
|
||||
<field name="title" select="1" />
|
||||
<field name="category_id" select="1"/>
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="vote_avg" />
|
||||
<field name="description" colspan="4" widget="text_wiki"/>
|
||||
<field name="state"/>
|
||||
<group colspan="2" col="3">
|
||||
<button name="idea_open" string="Open" states="draft" icon="gtk-go-forward"/>
|
||||
<button name="idea_close" string="Close" states="open" icon="gtk-close"/>
|
||||
<button name="idea_cancel" string="Cancel" states="open" icon="gtk-cancel"/>
|
||||
</group>
|
||||
<group col="6" colspan="4">
|
||||
<field name="title" colspan="4" 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>
|
||||
<notebook colspan="4">
|
||||
<page string="Idea Detail">
|
||||
<field name="description" nolabel="1" colspan="4" widget="text_wiki"/>
|
||||
</page>
|
||||
<page string="Comments">
|
||||
<page string="Comments" groups="base.group_extended">
|
||||
<field name="comment_ids" nolabel="1" colspan="4">
|
||||
<form string="Comment">
|
||||
<separator string="Your comment" colspan="4"/>
|
||||
@@ -159,27 +151,39 @@
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Vote">
|
||||
<field name="vote_ids" nolabel="1" colspan="4" />
|
||||
<page string="Vote" groups="base.group_extended">
|
||||
<field name="vote_ids" nolabel="1" colspan="4" readonly="True"/>
|
||||
</page>
|
||||
<page string="Statistics">
|
||||
<group col="6" colspan="4">
|
||||
<field name="count_comments" />
|
||||
<field name="count_votes" />
|
||||
</group>
|
||||
<field name="stat_vote_ids" colspan="4" mode="graph,tree" nolabel="1">
|
||||
<graph string="vote_stat of ideas" type="bar">
|
||||
<graph string="Vots Statistics" type="bar">
|
||||
<field name="score"/>
|
||||
<field name="nbr"/>
|
||||
</graph>
|
||||
<tree string="vote_stat of ideas">
|
||||
<tree string="Vots Statistics">
|
||||
<field name="score"/>
|
||||
<field name="nbr"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
<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"/>
|
||||
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- New Idea Tree View -->
|
||||
|
||||
<!-- New Idea Tree View -->
|
||||
|
||||
<record model="ir.ui.view" id="view_idea_idea_tree">
|
||||
<field name="name">idea.idea.tree</field>
|
||||
@@ -187,40 +191,47 @@
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="All Ideas">
|
||||
<field name="title"/>
|
||||
<field name="category_id" />
|
||||
<field name="create_date"/>
|
||||
<field name="user_id" />
|
||||
<field name="title"/>
|
||||
<field name="vote_avg" />
|
||||
<field name="vote_avg" widget="progressbar"/>
|
||||
<field name="count_comments" />
|
||||
<field name="count_votes" />
|
||||
<button name="%(action_idea_post_vote)d" icon="gtk-execute"
|
||||
type="action" states="draft,open" string="Vote" />
|
||||
<field name="state"/>
|
||||
<button name="%(action_idea_post_vote)d" icon="gtk-execute" type="action" states="draft,open" string="Vote"/>
|
||||
<button name="idea_close" string="Accept" states="open" icon="gtk-jump-to"/>
|
||||
<button name="idea_cancel" string="Refuse" states="open" icon="gtk-cancel"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Search Idea -->
|
||||
<!-- Search Idea -->
|
||||
|
||||
<record model="ir.ui.view" id="view_idea_idea_search">
|
||||
<field name="name">idea.idea.search</field>
|
||||
<field name="model">idea.idea</field>
|
||||
<field name="type">search</field>
|
||||
<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"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="gtk-execute" string="Draft"
|
||||
domain="[('state','=','draft')]" help="Draft Ideas" />
|
||||
<filter icon="gtk-execute" 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"/>
|
||||
</group>
|
||||
</search>
|
||||
<search string="Ideas">
|
||||
<group col="10" colspan="4">
|
||||
<filter icon="gtk-execute" string="My Ideas" domain="[('user_id','=',uid)]" help="My Ideas"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="gtk-execute" string="Draft"
|
||||
domain="[('state','=','draft')]" help="Draft Ideas" />
|
||||
<filter icon="gtk-execute" 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"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="1" string="Group By..." colspan="12" col="10">
|
||||
<filter icon="gtk-execute" string="Creator" help="By Creators" context="{'group_by':'user_id'}"/>
|
||||
<filter icon="gtk-execute" string="State" help="By States" context="{'group_by':'state'}"/>
|
||||
<filter icon="gtk-execute" string="Category" help="By Idea Category" context="{'group_by':'category_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -314,15 +325,15 @@
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,tree</field>
|
||||
</record>
|
||||
<menuitem name="Reporting" parent="base.menu_tools" id="base.menu_lunch_reporting" sequence="5"/>
|
||||
<menuitem name="Reporting" parent="base.menu_tools" id="base.menu_lunch_reporting" sequence="5"/>
|
||||
|
||||
<menuitem name="Idea" parent="base.menu_lunch_reporting" id="menu_idea_reporting"/>
|
||||
<menuitem name="Idea" parent="base.menu_lunch_reporting" id="menu_idea_reporting"/>
|
||||
|
||||
<menuitem name="Vote Statistics" parent="menu_idea_reporting"
|
||||
id="menu_idea_vote_stat" action="action_idea_vote_stat" />
|
||||
<menuitem name="Vote Statistics" parent="menu_idea_reporting"
|
||||
id="menu_idea_vote_stat" action="action_idea_vote_stat" />
|
||||
|
||||
<!-- Vote For Idea Action -->
|
||||
<record model="ir.actions.act_window" id="action_idea_vote">
|
||||
<!-- Vote For Idea Action -->
|
||||
<record model="ir.actions.act_window" id="action_idea_vote">
|
||||
<field name="name">Idea's vote</field>
|
||||
<field name="res_model">idea.vote</field>
|
||||
<field name="view_type">form</field>
|
||||
|
||||
@@ -29,13 +29,36 @@ class idea_post_vote(osv.osv_memory):
|
||||
_description = "Post vote"
|
||||
|
||||
_columns = {
|
||||
'vote': fields.selection([('-1', 'Not Voted'),
|
||||
('0', 'Very Bad'),
|
||||
('25', 'Bad'),
|
||||
('50', 'Normal'),
|
||||
('75', 'Good'),
|
||||
('100', 'Very Good') ], 'Post Vote', required=True)
|
||||
}
|
||||
'vote': fields.selection([('-1', 'Not Voted'),
|
||||
('0', 'Very Bad'),
|
||||
('25', 'Bad'),
|
||||
('50', 'Normal'),
|
||||
('75', 'Good'),
|
||||
('100', 'Very Good') ],
|
||||
'Post Vote', required=True),
|
||||
'note': fields.text('Description'),
|
||||
}
|
||||
|
||||
def get_default(self, cr, uid, context={}):
|
||||
"""
|
||||
This function checks for precondition before wizard executes
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param fields: List of fields for default value
|
||||
@param context: A standard dictionary for contextual values
|
||||
"""
|
||||
idea_obj = self.pool.get('idea.idea')
|
||||
|
||||
if context.get('active_id'):
|
||||
idea = idea_obj.browse(cr, uid, context.get('active_id'))
|
||||
return idea.my_vote
|
||||
else:
|
||||
return 75
|
||||
|
||||
_defaults = {
|
||||
'vote': get_default,
|
||||
}
|
||||
|
||||
def view_init(self, cr, uid, fields, context=None):
|
||||
"""
|
||||
@@ -50,16 +73,12 @@ class idea_post_vote(osv.osv_memory):
|
||||
|
||||
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 \
|
||||
ideas Could not be voted"))
|
||||
raise osv.except_osv(_("Warning !"), _("Draft/Accepted/Cancelled ideas Could not be voted"))
|
||||
if idea.state != 'open':
|
||||
raise osv.except_osv(_('Warning !'), _('idea should be in \
|
||||
\'Open\' state before vote for that idea.'))
|
||||
raise osv.except_osv(_('Warning !'), _('idea should be in \'Open\' state before vote for that idea.'))
|
||||
return False
|
||||
|
||||
|
||||
def do_vote(self, cr, uid, ids, context):
|
||||
|
||||
"""
|
||||
Create idea vote.
|
||||
@param cr: the current row, from the database cursor,
|
||||
@@ -67,15 +86,26 @@ 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')
|
||||
|
||||
vote_id = context and context.get('active_id', False) or False
|
||||
vote_pool = self.pool.get('idea.vote')
|
||||
comment_pool = self.pool.get('idea.comment')
|
||||
|
||||
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 }
|
||||
|
||||
vote = vote_obj.create(cr, uid, dic)
|
||||
comment = do_vote_obj['note']
|
||||
vote = {
|
||||
'idea_id': vote_id,
|
||||
'user_id': uid,
|
||||
'score': score
|
||||
}
|
||||
comment = {
|
||||
'user_id':uid,
|
||||
'idea_id':vote_id,
|
||||
'content': comment,
|
||||
}
|
||||
vote = vote_pool.create(cr, uid, vote)
|
||||
comment = comment_pool.create(cr, uid, comment)
|
||||
return {}
|
||||
|
||||
idea_post_vote()
|
||||
|
||||
@@ -2,43 +2,38 @@
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Post Idea for vote Form View -->
|
||||
<!-- Post Idea for vote Form View -->
|
||||
|
||||
<record id="view_idea_post_vote" model="ir.ui.view">
|
||||
<field name="name">idea.post.vote.form</field>
|
||||
<field name="model">idea.post.vote</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Create Tasks">
|
||||
<group colspan="4" >
|
||||
<field name="vote"/>
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-ok" name="do_vote" string="Post Vote" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_idea_post_vote" model="ir.ui.view">
|
||||
<field name="name">idea.post.vote.form</field>
|
||||
<field name="model">idea.post.vote</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Create Tasks">
|
||||
<group colspan="4" >
|
||||
<field name="vote" colspan="4"/>
|
||||
<separator string="Comment" colspan="4"/>
|
||||
<field name="note" colspan="4" nolabel="1"/>
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-ok" name="do_vote" string="Post Vote" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</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"
|
||||
key2="client_action_multi" name="vote"
|
||||
res_model="idea.post.vote" src_model="idea.idea"
|
||||
view_mode="form" target="new" view_type="form" />
|
||||
<!-- 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>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user