[IMP]: idea: Converted wizards to osv_memory wizards
bzr revid: atp@tinyerp.co.in-20100316053516-tpdi2y903jsrst7w
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
'depends': ['base'],
|
||||
'init_xml': [],
|
||||
'update_xml': [
|
||||
'idea_wizard.xml',
|
||||
'wizard/idea_post_vote_view.xml',
|
||||
'idea_view.xml',
|
||||
'idea_workflow.xml',
|
||||
'security/idea_security.xml',
|
||||
|
||||
@@ -166,7 +166,7 @@
|
||||
<field name="vote_avg" />
|
||||
<field name="count_comments" />
|
||||
<field name="count_votes" />
|
||||
<button name="%(wizard_idea_post_vote)d" icon="gtk-execute" type="action" states="draft,open" string="Vote"/>
|
||||
<button name="%(action_idea_post_vote)d" icon="gtk-execute" type="action" states="draft,open" string="Vote"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<wizard
|
||||
id="wizard_idea_post_vote"
|
||||
model="idea.idea"
|
||||
name="idea.post.vote"
|
||||
menu="True"
|
||||
string="Vote"/>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -18,5 +18,5 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import idea_vote
|
||||
import idea_post_vote
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from osv import fields, osv
|
||||
|
||||
class idea_post_vote(osv.osv_memory):
|
||||
|
||||
_name = "idea.post.vote"
|
||||
_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)
|
||||
}
|
||||
|
||||
def do_vote(self, cr, uid, ids, context):
|
||||
"""
|
||||
Create idea vote.
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of Idea Post vote’s IDs.
|
||||
@return: Dictionary {}
|
||||
"""
|
||||
vote_obj = self.pool.get('idea.vote')
|
||||
for data in self.read(cr, uid, ids):
|
||||
score = str(data['vote'])
|
||||
dic = {'idea_id': context['active_id'], 'user_id': uid, 'score': score }
|
||||
vote = vote_obj.create(cr, uid, dic)
|
||||
return {}
|
||||
|
||||
idea_post_vote()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<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="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>
|
||||
<field name="context">{'record_id':active_id}</field>
|
||||
</record>
|
||||
|
||||
<!-- <record id="action_idea_post_vote_values" model="ir.values">
|
||||
<field name="model_id" ref="idea.model_idea_idea" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">vote</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_idea_post_vote'))"/>
|
||||
<field name="key">action</field>
|
||||
<field name="model">idea.idea</field>
|
||||
</record> -->
|
||||
|
||||
<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" />
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,63 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import ir
|
||||
from mx.DateTime import now
|
||||
import pooler
|
||||
import netsvc
|
||||
|
||||
vote_form = """<?xml version="1.0" ?>
|
||||
<form string="Create Tasks">
|
||||
<field name="vote"/>
|
||||
</form>"""
|
||||
|
||||
vote_fields = {
|
||||
'vote': {'string': 'Post Vote', 'type': 'selection',
|
||||
'selection': [('-1','Not Voted'),('0','Very Bad'),('25', 'Bad'),('50','Normal'),('75','Good'),('100','Very Good') ]},
|
||||
}
|
||||
|
||||
|
||||
|
||||
class idea_vote(wizard.interface):
|
||||
def _do_vote(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
vote_obj = pool.get('idea.vote')
|
||||
score=str(data['form']['vote'])
|
||||
dic={'idea_id' : data['id'], 'user_id' : uid, 'score' : score }
|
||||
vote=vote_obj.create(cr,uid,dic)
|
||||
return True
|
||||
|
||||
states = {
|
||||
'init':{
|
||||
'actions': [],
|
||||
'result': {'type':'form', 'arch':vote_form, 'fields':vote_fields, 'state':[('end', 'Cancel'), ('post', 'Post Vote')] },
|
||||
},
|
||||
'post':{
|
||||
'actions': [],
|
||||
'result': {'type':'action', 'action': _do_vote, 'state':'end'},
|
||||
},
|
||||
}
|
||||
idea_vote('idea.post.vote')
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
Reference in New Issue
Block a user