Merge lp:~unifield-team/unifield-wm/utp-747 into lp:unifield-wm

Proposed by jftempo
Status: Merged
Merged at revision: 1844
Proposed branch: lp:~unifield-team/unifield-wm/utp-747
Merge into: lp:unifield-wm
Diff against target: 127 lines (+36/-4)
3 files modified
spreadsheet_xml/report/spreadsheet_writer_xls.mako (+3/-1)
supplier_catalogue/supplier_catalogue.py (+32/-3)
supplier_catalogue/supplier_catalogue_view.xml (+1/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/utp-747
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+194133@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'spreadsheet_xml/report/spreadsheet_writer_xls.mako'
2--- spreadsheet_xml/report/spreadsheet_writer_xls.mako 2013-05-22 07:12:03 +0000
3+++ spreadsheet_xml/report/spreadsheet_writer_xls.mako 2013-11-06 13:03:52 +0000
4@@ -76,7 +76,9 @@
5 % if h[1] == 'bool':
6 <Data ss:Type="Boolean">${result=='True' and '1' or '0'}</Data>
7 % elif h[1] in ('number', 'int', 'float'):
8- % if not isinstance(result, bool):
9+ % if isinstance(result, tuple) and len(result) > 1:
10+ <Data ss:Type="${result[1]}">${result[0]}</Data>
11+ % elif not isinstance(result, bool):
12 <Data ss:Type="Number">${result}</Data>
13 % else:
14 <Data ss:Type="String"></Data>
15
16=== modified file 'supplier_catalogue/supplier_catalogue.py'
17--- supplier_catalogue/supplier_catalogue.py 2013-07-09 07:16:03 +0000
18+++ supplier_catalogue/supplier_catalogue.py 2013-11-06 13:03:52 +0000
19@@ -35,6 +35,12 @@
20 from spreadsheet_xml.spreadsheet_xml import SpreadsheetXML
21 from spreadsheet_xml.spreadsheet_xml_write import SpreadsheetCreator
22
23+_HEADER_TYPE = {type('char'): 'string',
24+ type(1): 'number',
25+ type(1.00): 'number',
26+ type(long(1)): 'number',
27+ type(now()): 'datetime'}
28+
29 class supplier_catalogue(osv.osv):
30 _name = 'supplier.catalogue'
31 _description = 'Supplier catalogue'
32@@ -336,11 +342,23 @@
33 ('Min Quantity*', 'number'), ('Unit Price*', 'number'), ('Rounding', 'number'), ('Min Order Qty', 'number'),
34 ('Comment', 'string')]
35 lines_not_imported = [] # list of list
36+ t_dt = type(now())
37 for line in kwargs.get('line_with_error'):
38+ for f in line:
39+ if type(f) == t_dt:
40+ new_f = f.strftime('%Y-%m-%dT%H:%M:%S.000')
41+ line[line.index(f)] = (new_f, 'DateTime')
42+ elif isinstance(f, str) and columns_header[line.index(f)][1] != 'string':
43+ try:
44+ line[line.index(f)] = (float(f), 'Number')
45+ except:
46+ line[line.index(f)] = (f, 'String')
47+
48 if len(line) < len(columns_header):
49 lines_not_imported.append(line + ['' for x in range(len(columns_header)-len(line))])
50 else:
51 lines_not_imported.append(line)
52+
53 files_with_error = SpreadsheetCreator('Lines with errors', columns_header, lines_not_imported)
54 vals = {'data': base64.encodestring(files_with_error.get_xml(['decode.utf8'])),
55 'filename': 'Lines_Not_Imported.xls',
56@@ -400,30 +418,33 @@
57 if not code_ids:
58 default_code = obj_data.get_object_reference(cr, uid, 'msf_doc_import','product_tbd')[1]
59 to_correct_ok = True
60- error_list_line.append(_("The product was not found."))
61+ error_list_line.append(_("The product '%s' was not found.") % product_code)
62 else:
63 default_code = code_ids[0]
64 except Exception:
65 default_code = obj_data.get_object_reference(cr, uid, 'msf_doc_import','product_tbd')[1]
66 to_correct_ok = True
67- error_list_line.append(_("The product was not found."))
68+ error_list_line.append(_("The product '%s' was not found.") % product_code)
69
70 #Product UoM
71 p_uom = len(row.cells)>=3 and row.cells[2].data
72 if not p_uom:
73 uom_id = obj_data.get_object_reference(cr, uid, 'msf_doc_import','uom_tbd')[1]
74 to_correct_ok = True
75+ error_list_line.append(_("The UoM '%s' was not found.") % p_uom)
76 else:
77 try:
78 uom_name = p_uom.strip()
79 uom_ids = uom_obj.search(cr, uid, [('name', '=', uom_name)], context=context)
80 if not uom_ids:
81 uom_id = obj_data.get_object_reference(cr, uid, 'msf_doc_import','uom_tbd')[1]
82+ error_list_line.append(_("The UoM '%s' was not found.") % uom_name)
83 to_correct_ok = True
84 else:
85 uom_id = uom_ids[0]
86 except Exception:
87 uom_id = obj_data.get_object_reference(cr, uid, 'msf_doc_import','uom_tbd')[1]
88+ error_list_line.append(_("The UoM '%s' was not found.") % p_uom)
89 to_correct_ok = True
90 #[utp-129]: check consistency of uom
91 # I made the check on uom_id according to the constraint _check_uom in unifield-addons/product/product.py (l.744) so that we keep the consistency even when we create a supplierinfo directly from the product
92@@ -504,7 +525,8 @@
93 vals['line_ids'].append((0, 0, to_write))
94 # in case of lines ignored, we notify the user and create a file with the lines ignored
95 vals.update({'text_error': _('Lines ignored: %s \n ----------------------\n') % (ignore_lines,) +
96- '\n'.join(error_list), 'data': False, 'import_error_ok': False})
97+ '\n'.join(error_list), 'data': False, 'import_error_ok': False,
98+ 'file_to_import': False})
99 if line_with_error:
100 file_to_export = self.export_file_with_error(cr, uid, ids, line_with_error=line_with_error)
101 vals.update(file_to_export)
102@@ -520,6 +542,13 @@
103
104 return self.log(cr, uid, obj.id, msg_to_return,)
105
106+ def clear_error(self, cr, uid, ids, context=None):
107+ '''
108+ Remove the error list and the file with lines in error
109+ '''
110+ vals = {'data': False, 'text_error': '', 'import_error_ok': False}
111+ return self.write(cr, uid, ids, vals, context=context)
112+
113 def check_lines_to_fix(self, cr, uid, ids, context=None):
114 if isinstance(ids, (int, long)):
115 ids = [ids]
116
117=== modified file 'supplier_catalogue/supplier_catalogue_view.xml'
118--- supplier_catalogue/supplier_catalogue_view.xml 2013-05-13 13:36:18 +0000
119+++ supplier_catalogue/supplier_catalogue_view.xml 2013-11-06 13:03:52 +0000
120@@ -45,6 +45,7 @@
121 <button name="check_lines_to_fix" string="Check Lines" icon="gtk-dialog-warning" colspan="1" type="object" />
122 <field name="filename" invisible="1"/>
123 <field name="data" filename="filename" attrs="{'invisible': [('import_error_ok', '=', False)]}"/>
124+ <button name="clear_error" string="Clear errors" icon="gtk-clear" colspan="1" type="object" attrs="{'invisible': [('import_error_ok', '=', False)]}" />
125 <field name="import_error_ok" invisible="1"/>
126 <field name="text_error" colspan="4" attrs="{'invisible': [('import_error_ok', '=', False)]}" nolabel="1"/>
127 </group>

Subscribers

People subscribed via source and target branches