diff --git a/addons/idea/data/idea_workflow.xml b/addons/idea/data/idea_workflow.xml index 649541ae349..b460c73a6ed 100644 --- a/addons/idea/data/idea_workflow.xml +++ b/addons/idea/data/idea_workflow.xml @@ -7,53 +7,50 @@ True - + True - draft + normal function - idea_draft() + idea_set_normal_priority() - + - open + low function - idea_open() + idea_set_low_priority() - + - close + high function - idea_close() - True - - - - - cancel - function - idea_cancel() - True + idea_set_high_priority() - - - idea_open + + + idea_set_low_priority - - - idea_close + + + idea_set_normal_priority + + + + + + idea_set_high_priority - - - idea_cancel + + + idea_set_normal_priority diff --git a/addons/idea/demo/idea.xml b/addons/idea/demo/idea.xml index fea9d5535b5..2b4ff58b973 100644 --- a/addons/idea/demo/idea.xml +++ b/addons/idea/demo/idea.xml @@ -23,43 +23,45 @@ Communicate using emails I start communicating with prospects more by email than phonecalls. I send an email to create a sense of emergency, like "can I call you this week about our quote?" and I call only those that answer this email. + open - + Use a two-stages testing phase We should perform testing using two levels of validation. + open - + Write some functional documentation about procurements We receive many questions about OpenChatter. Maybe some functional doc could save us some time. + open - Better management of smtp errors There should be away to store the reason why some emails are not sent. + close - - + Kitten mode enabled by default As this is the most loved feature, the kitten mode should be enabled by default. And maybe even impossible to remove. + cancel - - + 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_set_low_priority(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'priority': 'low'}, context=context) - def idea_open(self, cr, uid, ids, context={}): - return self.write(cr, uid, ids, {'state': 'open'}, context=context) + def idea_set_normal_priority(self, cr, uid, ids, context={}): + return self.write(cr, uid, ids, {'priority': 'normal'}, 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) + def idea_set_high_priority(self, cr, uid, ids, context={}): + return self.write(cr, uid, ids, {'priority': 'high'}, context=context) diff --git a/addons/idea/views/idea.xml b/addons/idea/views/idea.xml index d6813d4112a..87094a29ace 100644 --- a/addons/idea/views/idea.xml +++ b/addons/idea/views/idea.xml @@ -7,10 +7,11 @@ idea.idea + -
+
í @@ -42,16 +43,20 @@
-