From 145befd3e73905e23688bacfafc27ae51468aa7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 17 Jun 2013 13:27:34 +0200 Subject: [CLEAN] [IMP] Idea: - created models/views/tests/data/demo directories, moved existing files into them - reorganized menus (less depth) - removed inherit and dependance from mail.thread (basic idea = without mail.thread -> will be added further) - removed custom tools user group - added basic files for test, currently void bzr revid: tde@openerp.com-20130617112734-4vhj6sjbvip0ufuv --- addons/idea/models/__init__.py | 22 +++++++++++ addons/idea/models/idea.py | 87 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 addons/idea/models/__init__.py create mode 100644 addons/idea/models/idea.py (limited to 'addons/idea/models') diff --git a/addons/idea/models/__init__.py b/addons/idea/models/__init__.py new file mode 100644 index 00000000000..e8a48771771 --- /dev/null +++ b/addons/idea/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2013-TODAY OpenERP S.A. +# +# 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 . +# +############################################################################## + +import idea diff --git a/addons/idea/models/idea.py b/addons/idea/models/idea.py new file mode 100644 index 00000000000..5bfcdb0c317 --- /dev/null +++ b/addons/idea/models/idea.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-Today OpenERP S.A. (). +# +# 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 . +# +############################################################################## + +from openerp.osv import osv +from openerp.osv import fields + + +VoteValues = [('-1', 'Not Voted'), ('0', 'Very Bad'), ('25', 'Bad'), \ + ('50', 'Normal'), ('75', 'Good'), ('100', 'Very Good')] +DefaultVoteValue = '50' + + +class idea_category(osv.osv): + """ Category of Idea """ + _name = "idea.category" + _description = "Idea Category" + _order = 'name asc' + + _columns = { + 'name': fields.char('Category Name', size=64, required=True), + } + + _sql_constraints = [ + ('name', 'unique(name)', 'The name of the category must be unique') + ] + + +class idea_idea(osv.osv): + """ Model of an Idea """ + _name = 'idea.idea' + _description = 'Propose and Share your Ideas' + _rec_name = 'name' + _order = 'name asc' + # _inherit = ['mail.thread'] + + _columns = { + 'create_uid': fields.many2one('res.users', 'Creator', required=True, readonly=True), + 'name': fields.char('Idea Summary', size=64, required=True, readonly=True, + states={'draft': [('readonly', False)]}, + oldname='title'), + 'description': fields.text('Description', readonly=True, + states={'draft': [('readonly', False)]}, + help='Content of the idea'), + 'category_ids': fields.many2many('idea.category', string='Tags', readonly=True, + states={'draft': [('readonly', False)]}), + 'state': fields.selection([('draft', 'New'), + ('open', 'Accepted'), + ('cancel', 'Refused'), + ('close', 'Done')], + 'Status', readonly=True, track_visibility='onchange'), + } + _sql_constraints = [ + ('name', 'unique(name)', 'The name of the idea must be unique') + ] + _defaults = { + 'state': lambda *a: 'draft', + } + + def idea_cancel(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'state': 'cancel'}, context=context) + + def idea_open(self, cr, uid, ids, context={}): + return self.write(cr, uid, ids, {'state': 'open'}, context=context) + + def idea_close(self, cr, uid, ids, context={}): + return self.write(cr, uid, ids, {'state': 'close'}, context=context) + + def idea_draft(self, cr, uid, ids, context={}): + return self.write(cr, uid, ids, {'state': 'draft'}, context=context) -- cgit v1.2.3 From f470535b0ece858f8cc98a7f846b26b9126cc4c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 18 Jun 2013 10:08:20 +0200 Subject: [ADD] idea: added a kanban view bzr revid: tde@openerp.com-20130618080820-18bhrsq3flfacpjl --- addons/idea/models/idea.py | 52 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 9 deletions(-) (limited to 'addons/idea/models') diff --git a/addons/idea/models/idea.py b/addons/idea/models/idea.py index 5bfcdb0c317..e491c06c2a5 100644 --- a/addons/idea/models/idea.py +++ b/addons/idea/models/idea.py @@ -28,7 +28,7 @@ VoteValues = [('-1', 'Not Voted'), ('0', 'Very Bad'), ('25', 'Bad'), \ DefaultVoteValue = '50' -class idea_category(osv.osv): +class IdeaCategory(osv.Model): """ Category of Idea """ _name = "idea.category" _description = "Idea Category" @@ -43,13 +43,18 @@ class idea_category(osv.osv): ] -class idea_idea(osv.osv): +class IdeaIdea(osv.Model): """ Model of an Idea """ _name = 'idea.idea' _description = 'Propose and Share your Ideas' _rec_name = 'name' _order = 'name asc' - # _inherit = ['mail.thread'] + + def _get_state_list(self, cr, uid, context=None): + return [('draft', 'New'), + ('open', 'Accepted'), + ('cancel', 'Refused'), + ('close', 'Done')] _columns = { 'create_uid': fields.many2one('res.users', 'Creator', required=True, readonly=True), @@ -61,19 +66,48 @@ class idea_idea(osv.osv): help='Content of the idea'), 'category_ids': fields.many2many('idea.category', string='Tags', readonly=True, states={'draft': [('readonly', False)]}), - 'state': fields.selection([('draft', 'New'), - ('open', 'Accepted'), - ('cancel', 'Refused'), - ('close', 'Done')], - 'Status', readonly=True, track_visibility='onchange'), + 'state': fields.selection(_get_state_list, string='Status', + readonly=True, track_visibility='onchange'), } + _sql_constraints = [ ('name', 'unique(name)', 'The name of the idea must be unique') ] + _defaults = { - 'state': lambda *a: 'draft', + 'state': lambda self, cr, uid, ctx=None: self._get_state_list(cr, uid, ctx)[0][0], } + #------------------------------------------------------ + # Technical stuff + #------------------------------------------------------ + + def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False): + """ Override read_group to always display all states. """ + # Default result structure + states = self._get_state_list(cr, uid, context=context) + read_group_all_states = [{ + '__context': {'group_by': groupby[1:]}, + '__domain': domain + [('state', '=', state_value)], + 'state': state_value, + 'state_count': 0, + } for state_value, state_name in states] + # Get standard results + read_group_res = super(IdeaIdea, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context, orderby) + # Update standard results with default results + result = [] + for state_value, state_name in states: + res = filter(lambda x: x['state'] == state_value, read_group_res) + if not res: + res = filter(lambda x: x['state'] == state_value, read_group_all_states) + res[0]['state'] = [state_value, state_name] + result.append(res[0]) + return result + + #------------------------------------------------------ + # Workflow / Actions + #------------------------------------------------------ + def idea_cancel(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'state': 'cancel'}, context=context) -- cgit v1.2.3 From 8c5428d33f26bd99e3e34f5230a8d5a107803bd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 18 Jun 2013 11:47:54 +0200 Subject: [IMP] Idea: create_uid -> user_id (to be tracked by chatter); improved some views; cleaned and improved demo data. bzr revid: tde@openerp.com-20130618094754-wlgx7vl2uo4pshfg --- addons/idea/models/idea.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'addons/idea/models') diff --git a/addons/idea/models/idea.py b/addons/idea/models/idea.py index e491c06c2a5..69a94598bad 100644 --- a/addons/idea/models/idea.py +++ b/addons/idea/models/idea.py @@ -52,13 +52,13 @@ class IdeaIdea(osv.Model): def _get_state_list(self, cr, uid, context=None): return [('draft', 'New'), - ('open', 'Accepted'), - ('cancel', 'Refused'), - ('close', 'Done')] + ('open', 'In discussion'), + ('close', 'Accepted'), + ('cancel', 'Refused')] _columns = { - 'create_uid': fields.many2one('res.users', 'Creator', required=True, readonly=True), - 'name': fields.char('Idea Summary', size=64, required=True, readonly=True, + 'user_id': fields.many2one('res.users', 'Responsible', required=True, readonly=True), + 'name': fields.char('Idea Summary', required=True, readonly=True, states={'draft': [('readonly', False)]}, oldname='title'), 'description': fields.text('Description', readonly=True, @@ -66,8 +66,7 @@ class IdeaIdea(osv.Model): help='Content of the idea'), 'category_ids': fields.many2many('idea.category', string='Tags', readonly=True, states={'draft': [('readonly', False)]}), - 'state': fields.selection(_get_state_list, string='Status', - readonly=True, track_visibility='onchange'), + 'state': fields.selection(_get_state_list, string='Status'), } _sql_constraints = [ @@ -75,6 +74,7 @@ class IdeaIdea(osv.Model): ] _defaults = { + 'user_id': lambda self, cr, uid, ctx=None: uid, 'state': lambda self, cr, uid, ctx=None: self._get_state_list(cr, uid, ctx)[0][0], } -- cgit v1.2.3 From 8c36f2724341e06abb801379208d2ccc40ad65ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 18 Jun 2013 12:16:21 +0200 Subject: [IMP] Idea: added mail as a dependancy to have already menus and everything ready to include chatter stuff inside the module. Easier for demos. bzr revid: tde@openerp.com-20130618101621-4f5me8grml002xci --- addons/idea/models/idea.py | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/idea/models') diff --git a/addons/idea/models/idea.py b/addons/idea/models/idea.py index 69a94598bad..678cc6e3632 100644 --- a/addons/idea/models/idea.py +++ b/addons/idea/models/idea.py @@ -47,6 +47,7 @@ class IdeaIdea(osv.Model): """ Model of an Idea """ _name = 'idea.idea' _description = 'Propose and Share your Ideas' + _rec_name = 'name' _order = 'name asc' -- cgit v1.2.3 From 4c9333c802f1547aa4d77f68963997c53f9f343c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 18 Jun 2013 13:19:24 +0200 Subject: [IMP] Idea: removed dead code, updated slighty the model to be able to change user_id and other things like taht. bzr revid: tde@openerp.com-20130618111924-f34uih1qag7sykp9 --- addons/idea/models/idea.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'addons/idea/models') diff --git a/addons/idea/models/idea.py b/addons/idea/models/idea.py index 678cc6e3632..b9ba80fb251 100644 --- a/addons/idea/models/idea.py +++ b/addons/idea/models/idea.py @@ -23,11 +23,6 @@ from openerp.osv import osv from openerp.osv import fields -VoteValues = [('-1', 'Not Voted'), ('0', 'Very Bad'), ('25', 'Bad'), \ - ('50', 'Normal'), ('75', 'Good'), ('100', 'Very Good')] -DefaultVoteValue = '50' - - class IdeaCategory(osv.Model): """ Category of Idea """ _name = "idea.category" @@ -58,15 +53,14 @@ class IdeaIdea(osv.Model): ('cancel', 'Refused')] _columns = { - 'user_id': fields.many2one('res.users', 'Responsible', required=True, readonly=True), - 'name': fields.char('Idea Summary', required=True, readonly=True, + 'user_id': fields.many2one('res.users', 'Responsible', required=True), + 'name': fields.char('Summary', required=True, readonly=True, states={'draft': [('readonly', False)]}, oldname='title'), - 'description': fields.text('Description', readonly=True, + 'description': fields.text('Description', required=True, states={'draft': [('readonly', False)]}, help='Content of the idea'), - 'category_ids': fields.many2many('idea.category', string='Tags', readonly=True, - states={'draft': [('readonly', False)]}), + 'category_ids': fields.many2many('idea.category', string='Tags'), 'state': fields.selection(_get_state_list, string='Status'), } -- cgit v1.2.3 From aff7d457c47906d55798d450067a19786f64a52e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 18 Jun 2013 15:15:45 +0200 Subject: [IMP] idea: workflow moved on a new priority field to avoid issues with kanban / clickable statusbar widget. Added a color field depending on the priori field. Updated views accordingly. bzr revid: tde@openerp.com-20130618131545-33tht1ps4ayzk0so --- addons/idea/models/idea.py | 71 +++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 29 deletions(-) (limited to 'addons/idea/models') diff --git a/addons/idea/models/idea.py b/addons/idea/models/idea.py index b9ba80fb251..910a0de483d 100644 --- a/addons/idea/models/idea.py +++ b/addons/idea/models/idea.py @@ -52,6 +52,15 @@ class IdeaIdea(osv.Model): ('close', 'Accepted'), ('cancel', 'Refused')] + def _get_color(self, cr, uid, ids, fields, args, context=None): + res = dict.fromkeys(ids, 3) + for idea in self.browse(cr, uid, ids, context=context): + if idea.priority == 'low': + res[idea.id] = 0 + elif idea.priority == 'high': + res[idea.id] = 7 + return res + _columns = { 'user_id': fields.many2one('res.users', 'Responsible', required=True), 'name': fields.char('Summary', required=True, readonly=True, @@ -61,7 +70,10 @@ class IdeaIdea(osv.Model): states={'draft': [('readonly', False)]}, help='Content of the idea'), 'category_ids': fields.many2many('idea.category', string='Tags'), - 'state': fields.selection(_get_state_list, string='Status'), + 'state': fields.selection(_get_state_list, string='Status', required=True), + 'priority': fields.selection([('low', 'Low'), ('normal', 'Normal'), ('high', 'High')], + string='Priority', required=True), + 'color': fields.function(_get_color, type='integer', string='Color Index'), } _sql_constraints = [ @@ -71,6 +83,7 @@ class IdeaIdea(osv.Model): _defaults = { 'user_id': lambda self, cr, uid, ctx=None: uid, 'state': lambda self, cr, uid, ctx=None: self._get_state_list(cr, uid, ctx)[0][0], + 'priority': 'normal', } #------------------------------------------------------ @@ -79,38 +92,38 @@ class IdeaIdea(osv.Model): def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False): """ Override read_group to always display all states. """ - # Default result structure - states = self._get_state_list(cr, uid, context=context) - read_group_all_states = [{ - '__context': {'group_by': groupby[1:]}, - '__domain': domain + [('state', '=', state_value)], - 'state': state_value, - 'state_count': 0, - } for state_value, state_name in states] - # Get standard results - read_group_res = super(IdeaIdea, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context, orderby) - # Update standard results with default results - result = [] - for state_value, state_name in states: - res = filter(lambda x: x['state'] == state_value, read_group_res) - if not res: - res = filter(lambda x: x['state'] == state_value, read_group_all_states) - res[0]['state'] = [state_value, state_name] - result.append(res[0]) - return result + if groupby and groupby[0] == "state": + # Default result structure + states = self._get_state_list(cr, uid, context=context) + read_group_all_states = [{ + '__context': {'group_by': groupby[1:]}, + '__domain': domain + [('state', '=', state_value)], + 'state': state_value, + 'state_count': 0, + } for state_value, state_name in states] + # Get standard results + read_group_res = super(IdeaIdea, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context, orderby) + # Update standard results with default results + result = [] + for state_value, state_name in states: + res = filter(lambda x: x['state'] == state_value, read_group_res) + if not res: + res = filter(lambda x: x['state'] == state_value, read_group_all_states) + res[0]['state'] = [state_value, state_name] + result.append(res[0]) + return result + else: + return super(IdeaIdea, self).read_group(cr, uid, domain, fields, groupby, offset=offset, limit=limit, context=context, orderby=orderby) #------------------------------------------------------ # Workflow / Actions #------------------------------------------------------ - def idea_cancel(self, cr, uid, ids, context=None): - return self.write(cr, uid, ids, {'state': 'cancel'}, context=context) - - def idea_open(self, cr, uid, ids, context={}): - return self.write(cr, uid, ids, {'state': 'open'}, context=context) + def idea_set_low_priority(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'priority': 'low'}, context=context) - def idea_close(self, cr, uid, ids, context={}): - return self.write(cr, uid, ids, {'state': 'close'}, context=context) + def idea_set_normal_priority(self, cr, uid, ids, context={}): + return self.write(cr, uid, ids, {'priority': 'normal'}, context=context) - def idea_draft(self, cr, uid, ids, context={}): - return self.write(cr, uid, ids, {'state': 'draft'}, context=context) + def idea_set_high_priority(self, cr, uid, ids, context={}): + return self.write(cr, uid, ids, {'priority': 'high'}, context=context) -- cgit v1.2.3 From 3e6693e7311452d51a744ce4e172ab631880f83d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 25 Jun 2013 13:11:10 +0200 Subject: [CLEAN] Misc cleaning bzr revid: tde@openerp.com-20130625111110-awwcjpq00xhohz93 --- addons/idea/models/idea.py | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/idea/models') diff --git a/addons/idea/models/idea.py b/addons/idea/models/idea.py index 910a0de483d..61934cfc3b2 100644 --- a/addons/idea/models/idea.py +++ b/addons/idea/models/idea.py @@ -27,6 +27,7 @@ class IdeaCategory(osv.Model): """ Category of Idea """ _name = "idea.category" _description = "Idea Category" + _order = 'name asc' _columns = { -- cgit v1.2.3