Merge lp:~credativ/openobject-addons/elico-6.1-fixes-gap-analysis-aeroo-seq into lp:~openerp-community/openobject-addons/elico-6.1

Proposed by Tom Pickering
Status: Needs review
Proposed branch: lp:~credativ/openobject-addons/elico-6.1-fixes-gap-analysis-aeroo-seq
Merge into: lp:~openerp-community/openobject-addons/elico-6.1
Diff against target: 191 lines (+92/-7)
5 files modified
gap_analysis/gap_analysis.py (+6/-2)
gap_analysis_aeroo_report/report/gap_analysis_report.py (+54/-1)
gap_analysis_aeroo_report/wizard/wizard_view.py (+22/-1)
gap_analysis_aeroo_report/wizard/wizard_view.xml (+9/-2)
gap_analysis_project_long_term/gap_analysis_project_long_term.py (+1/-1)
To merge this branch: bzr merge lp:~credativ/openobject-addons/elico-6.1-fixes-gap-analysis-aeroo-seq
Reviewer Review Type Date Requested Status
OpenERP Community (OBSOLETE) Pending
Review via email: mp+218427@code.launchpad.net

Description of the change

This branch includes changes which allow users to specify the ordering of rows in the Gap Analysis Aeroo Report. The user is able to specify one of several sorting modes based on Phase, Category and Critical Level.

To post a comment you must log in.

Unmerged revisions

17. By Jacob Hicks (credativ)

[IMP] Add functionality to sort by critical level and incorporate this in to the other sorting mechanisms

16. By Tom Pickering

[IMP] Further UI tweaks - re-wording and re-positioning of UI elements.

15. By Tom Pickering

[IMP] Changes to UI layout and design to improve clarity.

14. By Tom Pickering

[FIX] The 'seq' field is now zero-padded so alphabetic sorting is accurate.

13. By Tom Pickering

[FIX] Sorting can now handle floating-point representations of phases. In addition, sequence sorting is now alphabetically by 'seq'.

12. By Tom Pickering

[FIX] Exported report lines are now sorted on category sequence rather than 'seq' field.

11. By Tom Pickering

[IMP] Gap Analysis aeroo report lines can now be sorted by sequence then phase, or by phase then sequence.

10. By Tom Pickering

[IMP] Lines in exported aeroo reports are now sorted based on phase and functionality category sequence.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gap_analysis/gap_analysis.py'
2--- gap_analysis/gap_analysis.py 2013-06-22 02:18:01 +0000
3+++ gap_analysis/gap_analysis.py 2014-05-06 13:40:19 +0000
4@@ -228,6 +228,10 @@
5 if type(ids) != type([]):
6 ids = [ids]
7
8+ cat_ids = gap_cat_pool.search(cr, uid, [], context=context)
9+ seq_components = gap_cat_pool.read(cr, uid, cat_ids, ['sequence'], context=context)
10+ max_seq_len = max([len(str(c['sequence'])) for c in seq_components])
11+
12 for gap_id in ids:
13 cr.execute("SELECT DISTINCT c.code FROM gap_analysis_line l, gap_analysis_functionality_category c WHERE l.category=c.id AND l.gap_id = %s",(gap_id,))
14 categ_codes = map(lambda x: x[0], cr.fetchall()) or []
15@@ -243,7 +247,7 @@
16 current_categ = categ
17 seq = ''
18 while current_categ:
19- seq = str(current_categ.sequence) + seq
20+ seq = str(current_categ.sequence).zfill(max_seq_len) + seq
21 current_categ = current_categ.parent_id or False
22
23 line_ids = gapline_pool.search(cr, uid, [('category','=',categ.id),('gap_id','=',gap_id)], order='critical desc, effort asc') or []
24@@ -475,4 +479,4 @@
25
26 gap_analysis_line()
27
28-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
29\ No newline at end of file
30+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
31
32=== modified file 'gap_analysis_aeroo_report/report/gap_analysis_report.py'
33--- gap_analysis_aeroo_report/report/gap_analysis_report.py 2013-06-22 02:18:01 +0000
34+++ gap_analysis_aeroo_report/report/gap_analysis_report.py 2014-05-06 13:40:19 +0000
35@@ -76,7 +76,59 @@
36 context.update({'workload_type_list':ranges_list})
37 return result
38
39+
40+ def sort_lines_by_phase(self, lines, context=None):
41+ lines_with_num_phase = []
42+ lines_with_alpha_phase = []
43+ for l in lines:
44+ try:
45+ float(l.phase)
46+ lines_with_num_phase.append(l)
47+ except ValueError:
48+ lines_with_alpha_phase.append(l)
49+
50+ sorted_num_phase = sorted(lines_with_num_phase , key=lambda l: float(l.phase))
51+ sorted_alpha_phase = sorted(lines_with_alpha_phase, key=lambda l: l.phase )
52+ return sorted_num_phase + sorted_alpha_phase
53+
54+
55+ def sort_lines_by_seq(self, lines, context=None):
56+ if not context:
57+ context = {}
58+
59+ return sorted(lines, key=lambda l: l.seq)
60+
61+ def sort_lines_by_crit(self, lines, context=None):
62+ if not context:
63+ context = {}
64+
65+ return sorted(lines, key=lambda l: l.critical, reverse=True)
66+
67+ def sort_lines(self, lines, context=None):
68+ if not context:
69+ context = {}
70+
71+ sort_mode = context.get('sort_mode', 'phaseseq')
72+
73+ # Because 'sorted' is guaranteed to be stable,
74+ # sorting by each key from the hierarchically lowest first
75+ # sorts lines as required.
76+ sorted_lines = []
77+ if sort_mode == 'phasecritseq':
78+ sorted_lines = self.sort_lines_by_seq(lines, context=context)
79+ sorted_lines = self.sort_lines_by_crit(lines, context=context)
80+ sorted_lines = self.sort_lines_by_phase(sorted_lines[:], context=context)
81+ elif sort_mode == 'seqphasecrit':
82+ sorted_lines = self.sort_lines_by_crit(lines, context=context)
83+ sorted_lines = self.sort_lines_by_phase(lines, context=context)
84+ sorted_lines = self.sort_lines_by_seq(sorted_lines[:], context=context)
85+ if sort_mode == 'critphaseseq':
86+ sorted_lines = self.sort_lines_by_seq(lines, context=context)
87+ sorted_lines = self.sort_lines_by_phase(sorted_lines[:], context=context)
88+ sorted_lines = self.sort_lines_by_crit(lines, context=context)
89+ return sorted_lines
90
91+
92 def get_lines(self, context=None):
93 if not context:
94 context = {}
95@@ -99,7 +151,8 @@
96 if active_id:
97 # First we get all the used category for this Gap Analysis
98 active_gap = gap_pool.browse(self.cr, self.uid, active_id)
99- for one_line in active_gap.gap_lines:
100+ ordered = self.sort_lines(active_gap.gap_lines, context=context)
101+ for one_line in ordered:
102 res = {}
103
104 res['functionality'] = one_line.functionality.name
105
106=== modified file 'gap_analysis_aeroo_report/wizard/wizard_view.py'
107--- gap_analysis_aeroo_report/wizard/wizard_view.py 2013-06-22 02:18:01 +0000
108+++ gap_analysis_aeroo_report/wizard/wizard_view.py 2014-05-06 13:40:19 +0000
109@@ -21,16 +21,37 @@
110 ##############################################################################
111
112 from osv import osv, fields
113+from osv.osv import except_osv
114 from tools.translate import _
115
116 class gap_analysis_wizard(osv.osv_memory):
117 _name='gap_analysis.gap_analysis_wizard'
118+
119+ def _get_sort_modes(self, cr, uid, context=None):
120+ return [('phasecritseq','Group by Phase'),('seqphasecrit', 'Group by Category'),('critphaseseq', 'Group by Critical Level')]
121+
122+ _columns = {
123+ 'sort_mode' : fields.selection(_get_sort_modes, string='Sorting', help='Use \'Group by Phase\' for generating a customer facing implementation breakdown. Use \'Group by Category\' for for planning the complete implementation for a single module (e.g. sales).'),
124+ }
125+
126+ _defaults = {
127+ 'sort_mode' : _get_sort_modes(None, None, None)[0],
128+ }
129
130 def print_xls(self, cr, uid, ids, context=None):
131 if context is None:
132 context = {}
133
134 data = {'model':'gap_analysis', 'ids':context.get('active_ids', []), 'id':ids[0], 'report_type': 'aeroo'}
135+ sort_mode = self.read(cr, uid, ids, ['sort_mode'], context=context)[0]['sort_mode']
136+
137+ if not sort_mode:
138+ raise except_osv(
139+ _('Error: Sort Mode Unspecified'),
140+ _('Please select a sort mode from the selection box.')
141+ )
142+ else:
143+ context.update(sort_mode=sort_mode)
144
145 return {
146 'type': 'ir.actions.report.xml',
147@@ -58,4 +79,4 @@
148 }
149 gap_analysis_tasks_list()
150
151-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
152\ No newline at end of file
153+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
154
155=== modified file 'gap_analysis_aeroo_report/wizard/wizard_view.xml'
156--- gap_analysis_aeroo_report/wizard/wizard_view.xml 2013-06-22 02:18:01 +0000
157+++ gap_analysis_aeroo_report/wizard/wizard_view.xml 2014-05-06 13:40:19 +0000
158@@ -8,7 +8,14 @@
159 <field name="arch" type="xml">
160 <form string="Gap Analysis Report Wizard">
161 <newline/>
162- <group col="4" colspan="4">
163+ <label colspan="4" nolabel="1" string="You can export a summary of the complete Gap Analysis to a spreadsheet for further checking or analysis."/>
164+ <group col="1" colspan="2"/>
165+ <group col="2" colspan="2">
166+ <field name="sort_mode" colspan="2"/>
167+ </group>
168+ <separator colspan="4"/>
169+ <group col="1" colspan="2"/>
170+ <group col="2" colspan="2">
171 <button icon="gtk-cancel" special="cancel" string="Cancel" colspan="1"/>
172 <button icon="gtk-print" name="print_xls" string="Generate XLS" type="object" colspan="1" default_focus="1" />
173 </group>
174@@ -76,4 +83,4 @@
175 target="new"
176 key2="client_action_multi" />
177 </data>
178-</openerp>
179\ No newline at end of file
180+</openerp>
181
182=== modified file 'gap_analysis_project_long_term/gap_analysis_project_long_term.py'
183--- gap_analysis_project_long_term/gap_analysis_project_long_term.py 2013-06-22 02:18:01 +0000
184+++ gap_analysis_project_long_term/gap_analysis_project_long_term.py 2014-05-06 13:40:19 +0000
185@@ -218,4 +218,4 @@
186
187 gap_analysis_line()
188
189-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
190\ No newline at end of file
191+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Subscribers

People subscribed via source and target branches