Merge lp:~credativ/openobject-addons/elico-6.1-fixes-gap-analysis-xls-import-warnings into lp:~openerp-community/openobject-addons/elico-6.1

Proposed by Tom Pickering on 2014-05-06
Status: Needs review
Proposed branch: lp:~credativ/openobject-addons/elico-6.1-fixes-gap-analysis-xls-import-warnings
Merge into: lp:~openerp-community/openobject-addons/elico-6.1
Diff against target: 120 lines (+52/-13)
1 file modified
gap_analysis/wizard/import_from_sheet.py (+52/-13)
To merge this branch: bzr merge lp:~credativ/openobject-addons/elico-6.1-fixes-gap-analysis-xls-import-warnings
Reviewer Review Type Date Requested Status
OpenERP Community (OBSOLETE) 2014-05-06 Pending
Review via email: mp+218433@code.launchpad.net

Description of the change

This branch improves the clarity of warning messages displayed when a user tries to import an invalid Gap Analysis from a spreadsheet.

To post a comment you must log in.

Unmerged revisions

10. By Tom Pickering on 2014-02-27

[IMP] Improvements to clarity of warnings during spreadsheet import.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gap_analysis/wizard/import_from_sheet.py'
2--- gap_analysis/wizard/import_from_sheet.py 2013-06-22 02:18:01 +0000
3+++ gap_analysis/wizard/import_from_sheet.py 2014-05-06 14:02:57 +0000
4@@ -125,10 +125,15 @@
5 def retrieve_gap_analysis(filecontents):
6 warning = ''
7 g_cat_pool = self.pool.get('gap_analysis.functionality.category')
8+ g_eft_pool = self.pool.get('gap_analysis.effort')
9 gap_lines_entries = {}
10 rb = open_workbook(file_contents=filecontents,formatting_info=True, encoding_override="utf-8")
11+ missing_categories = []
12+ missing_efforts = []
13+ sheet_count = 1
14
15 for rs in rb.sheets():
16+ line_count = 4
17 for line in range(3, rs.nrows):
18 try:
19 keep = getcell(rs, line, 1)
20@@ -168,22 +173,37 @@
21 total_dev = getfloat(getcell(rs, line,29))
22
23 if functionality:
24+ if effort:
25+ effort_ids = g_eft_pool.search(cr, uid, [('name','=',str(effort))], context=context)
26+ if not effort_ids:
27+ eft_str = str(effort)
28+ if eft_str not in missing_efforts:
29+ missing_efforts.append(eft_str)
30+ warning += 'Effort %s does not exist in OpenERP. Please create it first, then upload your Gap Analysis again.\n\n' % eft_str
31+
32 if category:
33 categ_ids = g_cat_pool.search(cr, uid, ['|',('name','ilike',category),('full_path','ilike',category)])
34 if categ_ids:
35- category = categ_ids[0]
36+ if not missing_efforts:
37+ category = categ_ids[0]
38
39- gap_line = GapLineTemp(gap_analysis, keep, functionality.strip(), function_desc, category, critical_level, phase, contributors, openerp_fct, basic_report, advan_report, basic_process, advan_process, basic_screen, advan_screen, basic_workflow, advan_workflow, acl, obj, calcul_field, basic_wizard, advan_wizard, effort, duration_wk, total_cost, total_analysis, total_dev, testing, training, project_mgmt)
40- if gap_line:
41- gap_lines_entries[rs.name.lower().strip() + str(line)] = gap_line
42+ gap_line = GapLineTemp(gap_analysis, keep, functionality.strip(), function_desc, category, critical_level, phase, contributors, openerp_fct, basic_report, advan_report, basic_process, advan_process, basic_screen, advan_screen, basic_workflow, advan_workflow, acl, obj, calcul_field, basic_wizard, advan_wizard, effort, duration_wk, total_cost, total_analysis, total_dev, testing, training, project_mgmt)
43+ if gap_line:
44+ gap_lines_entries[rs.name.lower().strip() + str(line)] = gap_line
45 else:
46- warning += 'The category ' + str(category) + ' does not exist in OpenERP. Please create it first, then upload you Gap analysis again.\n'
47+ cat_str = str(category)
48+ if cat_str not in missing_categories:
49+ missing_categories.append(cat_str)
50+ warning += 'The category %s does not exist in OpenERP. Please create it first, then upload your Gap Analysis again.\n\n' % cat_str
51 else:
52- warning += 'The category ' + str(category) + ' does not exist in OpenERP. Please create it first, then upload you Gap analysis again.\n'
53+ warning += 'Missing category in spreadsheet row %d. Please specify a category and upload your Gap Analysis again.\n\n' % line_count
54 else:
55 print(" ("+ str(line) +"), No functionality... ######################## .......")
56 except RuntimeError as error:
57 print(" ("+ str(line) +", "+ str(col) +"), didn't make it ######################## ......."+ str(error))
58+
59+ line_count += 1
60+ sheet_count += 1
61
62 if warning != '':
63 raise osv.except_osv(_('Error'), warning)
64@@ -342,8 +362,12 @@
65 g_cat_pool = self.pool.get('gap_analysis.functionality.category')
66 warning = ''
67 rb = open_workbook(file_contents=filecontents,formatting_info=True, encoding_override="utf-8")
68+ missing_categories = []
69+ missing_efforts = []
70+ sheet_count = 1
71
72- for rs in rb.sheets():
73+ for rs in rb.sheets():
74+ line_count = 4
75 for line in range(3, rs.nrows):
76 try:
77 keep = False
78@@ -378,21 +402,36 @@
79 category = getcell(rs, line, 25, forceText=True)
80
81 if functionality:
82+ if effort:
83+ effort_ids = g_eft_pool.search(cr, uid, [('name','=',str(effort))], context=context)
84+ if not effort_ids:
85+ eft_str = str(effort)
86+ if eft_str not in missing_efforts:
87+ missing_efforts.append(eft_str)
88+ warning += 'Effort %s does not exist in OpenERP. Please create it first, then upload your Gap Analysis again.\n\n' % eft_str
89+
90 if category:
91 categ_ids = g_cat_pool.search(cr, uid, ['|',('name','ilike',category),('full_path','ilike',category)])
92 if categ_ids:
93- category = categ_ids[0]
94- one_fct = GapLineTemp(gap_analysis, keep, functionality.strip(), function_desc, category, critical_level, phase, contributors, openerp_fct, basic_report, advan_report, basic_process, advan_process, basic_screen, advan_screen, basic_workflow, advan_workflow, acl, obj, calcul_field, basic_wizard, advan_wizard, effort, duration_wk, total_cost, total_analysis, total_dev, testing, training, project_mgmt)
95- if one_fct:
96- fct_entries[rs.name.lower().strip() + str(line)] = one_fct
97+ if not missing_efforts:
98+ category = categ_ids[0]
99+ one_fct = GapLineTemp(gap_analysis, keep, functionality.strip(), function_desc, category, critical_level, phase, contributors, openerp_fct, basic_report, advan_report, basic_process, advan_process, basic_screen, advan_screen, basic_workflow, advan_workflow, acl, obj, calcul_field, basic_wizard, advan_wizard, effort, duration_wk, total_cost, total_analysis, total_dev, testing, training, project_mgmt)
100+ if one_fct:
101+ fct_entries[rs.name.lower().strip() + str(line)] = one_fct
102 else:
103- warning += 'The category ' + str(category) + ' dont exist in OpenERP. Please create it first, then upload you Gap analysis.\n'
104+ cat_str = str(category)
105+ if cat_str not in missing_categories:
106+ missing_categories.append(cat_str)
107+ warning += 'The category %s does not exist in OpenERP. Please create it first, then upload your Gap Analysis again.\n\n' % cat_id
108 else:
109- warning += 'The category ' + str(category) + ' dont exist in OpenERP. Please create it first, then upload you Gap analysis.\n'
110+ warning += 'Missing category in spreadsheet row %d. Please specify a category and upload your Gap Analysis again.\n\n' % line_count
111 else:
112 print(" ("+ str(line) +"), No functionality... ######################## .......")
113 except RuntimeError as error:
114 print(" ("+ str(line) +", "+ str(col) +"), didn't make it ######################## ......."+ str(error))
115+
116+ line_count += 1
117+ sheet_count += 1
118
119 if warning != '':
120 raise osv.except_osv(_('Error'), warning)

Subscribers

People subscribed via source and target branches