diff options
| author | Vir (Open ERP) <vir@tinyerp.com> | 2010-06-02 13:53:32 +0530 |
|---|---|---|
| committer | Vir (Open ERP) <vir@tinyerp.com> | 2010-06-02 13:53:32 +0530 |
| commit | a00a181d98fdb43a9987e8117ef70eac2d09638a (patch) | |
| tree | ffe3e986d4427b3132e268e2c83ba11fca27eb62 /addons/idea | |
| parent | d1cfcf4c5cf99b98883613418d076e606864e8b7 (diff) | |
| parent | 8397cd973da9ae5033ad11a3c121f02e6aa7d653 (diff) | |
[Merge] Merge with trunk addons
bzr revid: vir@tinyerp.com-20100602082332-bq3vbck48iyd4thx
Diffstat (limited to 'addons/idea')
| -rw-r--r-- | addons/idea/i18n/id.po | 2 | ||||
| -rw-r--r-- | addons/idea/idea.py | 19 | ||||
| -rw-r--r-- | addons/idea/idea_view.xml | 82 | ||||
| -rw-r--r-- | addons/idea/security/ir.model.access.csv | 3 | ||||
| -rw-r--r-- | addons/idea/test/test_idea.yml | 34 | ||||
| -rw-r--r-- | addons/idea/wizard/idea_post_vote.py | 97 | ||||
| -rw-r--r-- | addons/idea/wizard/idea_post_vote_view.xml | 40 |
7 files changed, 195 insertions, 82 deletions
diff --git a/addons/idea/i18n/id.po b/addons/idea/i18n/id.po index da1e1c37693..1ecdb11dd08 100644 --- a/addons/idea/i18n/id.po +++ b/addons/idea/i18n/id.po @@ -13,7 +13,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-06-01 03:44+0000\n" +"X-Launchpad-Export-Date: 2010-06-02 03:33+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: idea diff --git a/addons/idea/idea.py b/addons/idea/idea.py index e46115c5639..74c6de9f721 100644 --- a/addons/idea/idea.py +++ b/addons/idea/idea.py @@ -22,6 +22,7 @@ from osv import osv from osv import fields from tools.translate import _ +import time VoteValues = [('-1', 'Not Voted'), ('0', 'Very Bad'), ('25', 'Bad'), \ ('50', 'Normal'), ('75', 'Good'), ('100', 'Very Good') ] @@ -150,13 +151,12 @@ 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), + 'user_id': fields.many2one('res.users', 'Responsible', required=True, readonly=True), 'title': fields.char('Idea Summary', size=64, required=True), 'description': fields.text('Description', required=True, help='Content of the idea'), 'comment_ids': fields.one2many('idea.comment', 'idea_id', 'Comments'), - 'create_date': fields.datetime('Creation date', readonly=True), + 'created_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), 'vote_avg': fields.function(_vote_avg_compute, method=True, string="Average Score", type="float"), @@ -174,12 +174,16 @@ class idea_idea(osv.osv): ), 'visibility':fields.boolean('Open Idea?', required=False), 'stat_vote_ids': fields.one2many('idea.vote.stat', 'idea_id', 'Statistics', readonly=True), + 'vote_limit': 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', + 'vote_limit': lambda * a: 1, + 'created_date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), 'visibility': lambda *a: True, } _order = 'id desc' @@ -278,12 +282,15 @@ class idea_vote(osv.osv): _rec_name = 'score' _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) + 'user_id': fields.many2one('res.users', 'By user', readonly="True"), + 'idea_id': fields.many2one('idea.idea', 'Idea', readonly="True", ondelete='cascade'), + 'score': fields.selection(VoteValues, 'Vote Status', readonly="True"), + 'date': fields.datetime('Date', readonly="True"), + 'comment': fields.text('Comment', readonly="True"), } _defaults = { 'score': lambda *a: DefaultVoteValue, + 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), } idea_vote() diff --git a/addons/idea/idea_view.xml b/addons/idea/idea_view.xml index b268a64d991..18a268a410b 100644 --- a/addons/idea/idea_view.xml +++ b/addons/idea/idea_view.xml @@ -50,6 +50,7 @@ <menuitem name="Categories" parent="menu_ideas" id="menu_idea_category" action="action_idea_category" /> + <!-- Idea Category Action --> <record model="ir.actions.act_window" id="action_idea_category_tree"> @@ -60,8 +61,18 @@ </record> <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"/> + + <menuitem name="Give Vote" parent="menu_ideas1" + id="menu_give_vote" + action="action_idea_select"/> + -<!-- Oepn Ideas Action --> + <!-- Open Ideas Action --> <record model="ir.actions.act_window" id="action_idea_idea_categ_open"> <field name="name">Open Ideas</field> @@ -102,9 +113,9 @@ <field name="type">tree</field> <field name="arch" type="xml"> <tree string="Votes"> - <field name="idea_id"/> - <field name="user_id"/> - <field name="score" /> + <field name="user_id" /> + <field name="score"/> + <field name="date"/> </tree> </field> </record> @@ -117,12 +128,39 @@ <field name="type">form</field> <field name="arch" type="xml"> <form string="Votes"> - <field name="idea_id" select="1" /> - <field name="user_id" select="1" /> - <field name="score"/> + <group colspan="4"> + <field name="user_id" select="1" /> + <field name="date"/> + <newline/> + <field name="score"/> + </group> + <separator string="Comments:" colspan="4"/> + <field name="comment" colspan="4" nolabel="1"/> </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="Vote date" icon="terp-crm" domain="[]" context="{'group_by':'date'}"/> + <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 --> @@ -168,7 +206,8 @@ <field name="score"/> <field name="nbr"/> </tree> - </field> + </field> + </page> </notebook> <group colspan="4" col="6"> @@ -177,7 +216,6 @@ <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> @@ -190,15 +228,15 @@ <field name="model">idea.idea</field> <field name="type">tree</field> <field name="arch" type="xml"> - <tree string="All Ideas"> + <tree string="Ideas"> <field name="title"/> <field name="category_id" /> - <field name="create_date"/> + <field name="created_date"/> <field name="vote_avg" widget="progressbar"/> <field name="count_comments" /> <field name="count_votes" /> <field name="state"/> - <button name="%(action_idea_post_vote)d" icon="gtk-execute" type="action" states="draft,open" string="Vote"/> + <button name="%(idea.action_idea_post_vote)d" icon="gtk-execute" type="action" states="open" 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"/> </tree> @@ -233,23 +271,6 @@ </field> </record> -<!-- Comments on Idea Tree View --> - - <record model="ir.ui.view" id="view_idea_comment_tree"> - <field name="name">idea.comment.tree</field> - <field name="model">idea.comment</field> - <field name="type">tree</field> - <field name="arch" type="xml"> - <tree string="Comments"> - <field name="create_date" /> - <field name="user_id" /> - <field name="content" string="Comment" /> - </tree> - </field> - </record> - -<!-- Idea Action --> - <record model="ir.actions.act_window" id="action_idea_idea"> <field name="name">Ideas</field> <field name="res_model">idea.idea</field> @@ -337,9 +358,10 @@ <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"/> + <menuitem name="Votes" parent="menu_ideas" id="menu_idea_vote" action="action_idea_vote"/> </data> </openerp> diff --git a/addons/idea/security/ir.model.access.csv b/addons/idea/security/ir.model.access.csv index 0c720f2ee2d..0fe5dad9ac9 100644 --- a/addons/idea/security/ir.model.access.csv +++ b/addons/idea/security/ir.model.access.csv @@ -1,8 +1,9 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" "access_idea_category","idea.category","model_idea_category","base.group_user",1,0,0,0 "access_idea_idea","idea.idea","model_idea_idea","base.group_user",1,1,1,1 -"access_idea_comment","idea.comment","model_idea_comment","base.group_user",1,1,1,1 "access_idea_vote","idea.vote","model_idea_vote","base.group_user",1,1,1,1 "access_idea_vote_stat","idea.vote.stat","model_idea_vote_stat","base.group_user",1,0,0,0 "access_idea_category_system","idea.category system","model_idea_category","base.group_system",1,1,1,1 "idea_post_vote","idea.post.vote","model_idea_post_vote","base.group_user",1,1,1,1 +"access_idea_select","idea.select","model_idea_select","base.group_user",1,1,1,1 +"access_idea_comment","idea.comment","model_idea_comment","base.group_system",1,1,1,1 diff --git a/addons/idea/test/test_idea.yml b/addons/idea/test/test_idea.yml index 6714fbfc7e2..4c3f5301a5a 100644 --- a/addons/idea/test/test_idea.yml +++ b/addons/idea/test/test_idea.yml @@ -8,10 +8,10 @@ name: Technical - | I create a New Idea of "Technical presentation for 1 hours in every day" and specify category "Technical". - - !record {model: idea.idea, id: idea_idea_0}: category_id: idea_category_technical0 + created_date: '05/13/2010 19:16:26' description: I want that Technical presentation are arranged for 1 hours in every day.\nso, on that presentation, we can know all things what improvement and development are done in our company.\n\n\n\n\n @@ -44,52 +44,50 @@ !record {model: res.users, id: res_users_user1}: company_id: base.main_company context_lang: en_US + groups_id: + - base.group_system + - base.group_user login: user2 name: user2 password: user2 - | In order to post vote I connect as user1 and open the idea page - I click on "Vote" wizard and vote the idea as "Normal" + I click on "Submit Vote" wizard button and vote the idea as "Normal" - !record {model: idea.post.vote, id: idea_post_vote_0}: vote: 50 + - | - Now I click on "Post Vote" button of wizard. + Now I click on "Post" button of this wizard. - !python {model: idea.post.vote}: | uid = ref('res_users_user0') - self.do_vote(cr, uid, [ref("idea_post_vote_0")], {'active_id': ref('idea_idea_0')}) + self.do_vote(cr, uid, [ref("idea_post_vote_0")], {'active_ids': [ref('idea_idea_0')]}) - | - To add other vote I connect as user2 and open the idea page - I click on "Vote" wizard and vote the idea as "Very Good" + To add other vote I connect as user2 and open the idea page. + + I click on "Submit Vote" wizard button and vote the idea as "Very Good". + + and put comment "We can learn many things from technical presentation". - !record {model: idea.post.vote, id: idea_post_vote_1}: vote: 100 - + note: 'We can learn many things from technical presentation' - | - I click on "Post Vote" button of this wizard. + I click on "Post" button of this wizard. - !python {model: idea.post.vote}: | uid = ref('res_users_user1') - self.do_vote(cr, uid, [ref("idea_post_vote_1")], {'active_id': ref('idea_idea_0')}) + self.do_vote(cr, uid, [ref("idea_post_vote_1")], {'active_ids': [ref('idea_idea_0')]}) - | I can see that the Average score changed in "Average score" field with value 75 - !record {model: idea.idea, id: idea_idea_0}: vote_avg: 75 - -- | - I put one comment "We can learn many things from technical presentation" for the idea. -- - !record {model: idea.idea, id: idea.idea_idea_0}: - comment_ids: - - content: "We can learn many things from technical presentation" - idea_id: idea.idea_idea_0 - user_id: res_users_user1 - | I connect as Manager and close this idea by click on "Close" button. diff --git a/addons/idea/wizard/idea_post_vote.py b/addons/idea/wizard/idea_post_vote.py index f68496c8ae5..20ef22a5f2d 100644 --- a/addons/idea/wizard/idea_post_vote.py +++ b/addons/idea/wizard/idea_post_vote.py @@ -70,15 +70,28 @@ class idea_post_vote(osv.osv_memory): @param context: A standard dictionary for contextual values """ idea_obj = self.pool.get('idea.idea') - + vote_obj = self.pool.get('idea.vote') + 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")) + + for active_id in context.get('active_ids'): + + vote_ids = vote_obj.search(cr, uid, [('user_id', '=', uid), ('idea_id', '=', active_id)]) + vote_obj_id = vote_obj.browse(cr, uid, vote_ids) + count = 0 + for vote in vote_obj_id: + count += 1 + + user_limit = idea.vote_limit + if count >= user_limit: + raise osv.except_osv(_('Warning !'),_("You can not give Vote for this idea more than %s times") % (user_limit)) + 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): + def do_vote(self, cr, uid, ids, context=None): """ Create idea vote. @param cr: the current row, from the database cursor, @@ -87,30 +100,72 @@ class idea_post_vote(osv.osv_memory): @return: Dictionary {} """ - vote_id = context and context.get('active_id', False) or False + vote_ids = context and context.get('active_ids', []) or [] 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']) comment = do_vote_obj.get('note', False) - vote = { - 'idea_id': vote_id, - 'user_id': uid, - 'score': score - } - if comment: - comment = { - 'user_id':uid, - 'idea_id':vote_id, - 'content': comment, - } - comment = comment_pool.create(cr, uid, comment) + + for vote_id in vote_ids: - vote = vote_pool.create(cr, uid, vote) + vote = { + 'idea_id': vote_id, + 'user_id': uid, + 'score': score + } + if comment: + comment = { + 'user_id':uid, + 'idea_id':vote_id, + 'content': comment, + } + comment = comment_pool.create(cr, uid, comment) + + vote = vote_pool.create(cr, uid, vote) return {} - + idea_post_vote() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +class idea_select(osv.osv_memory): + + """ Select idea for vote.""" + + _name = "idea.select" + _description = "select idea" + + _columns = { + 'idea_id': fields.many2one('idea.idea', 'Idea', required=True), + } + + def open_vote(self, cr, uid, ids, context=None): + """ + This function load column. + @param cr: the current row, from the database cursor, + @param uid: the current users ID for security checks, + @param ids: List of load column, + @return: dictionary of query logs clear message window + """ + idea_obj = self.browse(cr, uid, ids) + for idea in idea_obj: + idea_id = idea.idea_id.id + + data_obj = self.pool.get('ir.model.data') + id2 = data_obj._get_id(cr, uid, 'idea', 'view_idea_post_vote') + if id2: + id2 = data_obj.browse(cr, uid, id2, context=context).res_id + value = { + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'idea.post.vote', + 'views': [(id2, 'form'), (False, 'tree'), (False, 'calendar'), (False, 'graph')], + 'type': 'ir.actions.act_window', + 'target': 'new', + 'context': {'active_ids': [idea_id]} + } + return value + +idea_select() +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/idea/wizard/idea_post_vote_view.xml b/addons/idea/wizard/idea_post_vote_view.xml index aa066cdffd3..ef1a338dcd4 100644 --- a/addons/idea/wizard/idea_post_vote_view.xml +++ b/addons/idea/wizard/idea_post_vote_view.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <openerp> <data> - <!-- Post Idea for vote Form View --> <record id="view_idea_post_vote" model="ir.ui.view"> @@ -9,7 +8,7 @@ <field name="model">idea.post.vote</field> <field name="type">form</field> <field name="arch" type="xml"> - <form string="Create Tasks"> + <form string="Give Vote"> <group colspan="4" > <field name="vote" colspan="4"/> <separator string="Comment" colspan="4"/> @@ -18,12 +17,33 @@ <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"/> + <button icon="gtk-ok" name="do_vote" string="Post" type="object"/> </group> </form> </field> </record> + + <record id="view_idea_select" model="ir.ui.view"> + <field name="name">idea.select.form</field> + <field name="model">idea.select</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Select Idea for Vote"> + <group colspan="4" > + <separator string="Select Idea for Vote" colspan="4"/> + <field name="idea_id"/> + </group> + <separator string="" colspan="4"/> + <group colspan="4" col="6"> + <label string="" colspan="2"/> + <button icon="gtk-cancel" special="cancel" string="Close"/> + <button icon="gtk-go-forward" name="open_vote" string="Next" type="object"/> + </group> + </form> + </field> + </record> + <!-- Post Idea for vote Action --> <record id="action_idea_post_vote" model="ir.actions.act_window"> @@ -33,7 +53,17 @@ <field name="view_mode">tree,form</field> <field name="view_id" ref="view_idea_post_vote"/> <field name="target">new</field> - </record> - + </record> + + <record id="action_idea_select" model="ir.actions.act_window"> + <field name="name">Idea select</field> + <field name="res_model">idea.select</field> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + <field name="view_id" ref="view_idea_select"/> + <field name="target">new</field> + <field name="context">{'model': 'idea.idea'}</field> + </record> + </data> </openerp> |
