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
=== modified file 'spreadsheet_xml/report/spreadsheet_writer_xls.mako'
--- spreadsheet_xml/report/spreadsheet_writer_xls.mako 2013-05-22 07:12:03 +0000
+++ spreadsheet_xml/report/spreadsheet_writer_xls.mako 2013-11-06 13:03:52 +0000
@@ -76,7 +76,9 @@
76 % if h[1] == 'bool':76 % if h[1] == 'bool':
77 <Data ss:Type="Boolean">${result=='True' and '1' or '0'}</Data>77 <Data ss:Type="Boolean">${result=='True' and '1' or '0'}</Data>
78 % elif h[1] in ('number', 'int', 'float'):78 % elif h[1] in ('number', 'int', 'float'):
79 % if not isinstance(result, bool): 79 % if isinstance(result, tuple) and len(result) > 1:
80 <Data ss:Type="${result[1]}">${result[0]}</Data>
81 % elif not isinstance(result, bool):
80 <Data ss:Type="Number">${result}</Data>82 <Data ss:Type="Number">${result}</Data>
81 % else:83 % else:
82 <Data ss:Type="String"></Data>84 <Data ss:Type="String"></Data>
8385
=== modified file 'supplier_catalogue/supplier_catalogue.py'
--- supplier_catalogue/supplier_catalogue.py 2013-07-09 07:16:03 +0000
+++ supplier_catalogue/supplier_catalogue.py 2013-11-06 13:03:52 +0000
@@ -35,6 +35,12 @@
35from spreadsheet_xml.spreadsheet_xml import SpreadsheetXML35from spreadsheet_xml.spreadsheet_xml import SpreadsheetXML
36from spreadsheet_xml.spreadsheet_xml_write import SpreadsheetCreator36from spreadsheet_xml.spreadsheet_xml_write import SpreadsheetCreator
3737
38_HEADER_TYPE = {type('char'): 'string',
39 type(1): 'number',
40 type(1.00): 'number',
41 type(long(1)): 'number',
42 type(now()): 'datetime'}
43
38class supplier_catalogue(osv.osv):44class supplier_catalogue(osv.osv):
39 _name = 'supplier.catalogue'45 _name = 'supplier.catalogue'
40 _description = 'Supplier catalogue'46 _description = 'Supplier catalogue'
@@ -336,11 +342,23 @@
336 ('Min Quantity*', 'number'), ('Unit Price*', 'number'), ('Rounding', 'number'), ('Min Order Qty', 'number'),342 ('Min Quantity*', 'number'), ('Unit Price*', 'number'), ('Rounding', 'number'), ('Min Order Qty', 'number'),
337 ('Comment', 'string')]343 ('Comment', 'string')]
338 lines_not_imported = [] # list of list344 lines_not_imported = [] # list of list
345 t_dt = type(now())
339 for line in kwargs.get('line_with_error'):346 for line in kwargs.get('line_with_error'):
347 for f in line:
348 if type(f) == t_dt:
349 new_f = f.strftime('%Y-%m-%dT%H:%M:%S.000')
350 line[line.index(f)] = (new_f, 'DateTime')
351 elif isinstance(f, str) and columns_header[line.index(f)][1] != 'string':
352 try:
353 line[line.index(f)] = (float(f), 'Number')
354 except:
355 line[line.index(f)] = (f, 'String')
356
340 if len(line) < len(columns_header):357 if len(line) < len(columns_header):
341 lines_not_imported.append(line + ['' for x in range(len(columns_header)-len(line))])358 lines_not_imported.append(line + ['' for x in range(len(columns_header)-len(line))])
342 else:359 else:
343 lines_not_imported.append(line)360 lines_not_imported.append(line)
361
344 files_with_error = SpreadsheetCreator('Lines with errors', columns_header, lines_not_imported)362 files_with_error = SpreadsheetCreator('Lines with errors', columns_header, lines_not_imported)
345 vals = {'data': base64.encodestring(files_with_error.get_xml(['decode.utf8'])),363 vals = {'data': base64.encodestring(files_with_error.get_xml(['decode.utf8'])),
346 'filename': 'Lines_Not_Imported.xls',364 'filename': 'Lines_Not_Imported.xls',
@@ -400,30 +418,33 @@
400 if not code_ids:418 if not code_ids:
401 default_code = obj_data.get_object_reference(cr, uid, 'msf_doc_import','product_tbd')[1]419 default_code = obj_data.get_object_reference(cr, uid, 'msf_doc_import','product_tbd')[1]
402 to_correct_ok = True420 to_correct_ok = True
403 error_list_line.append(_("The product was not found."))421 error_list_line.append(_("The product '%s' was not found.") % product_code)
404 else:422 else:
405 default_code = code_ids[0]423 default_code = code_ids[0]
406 except Exception:424 except Exception:
407 default_code = obj_data.get_object_reference(cr, uid, 'msf_doc_import','product_tbd')[1]425 default_code = obj_data.get_object_reference(cr, uid, 'msf_doc_import','product_tbd')[1]
408 to_correct_ok = True426 to_correct_ok = True
409 error_list_line.append(_("The product was not found."))427 error_list_line.append(_("The product '%s' was not found.") % product_code)
410428
411 #Product UoM429 #Product UoM
412 p_uom = len(row.cells)>=3 and row.cells[2].data430 p_uom = len(row.cells)>=3 and row.cells[2].data
413 if not p_uom:431 if not p_uom:
414 uom_id = obj_data.get_object_reference(cr, uid, 'msf_doc_import','uom_tbd')[1]432 uom_id = obj_data.get_object_reference(cr, uid, 'msf_doc_import','uom_tbd')[1]
415 to_correct_ok = True433 to_correct_ok = True
434 error_list_line.append(_("The UoM '%s' was not found.") % p_uom)
416 else:435 else:
417 try:436 try:
418 uom_name = p_uom.strip()437 uom_name = p_uom.strip()
419 uom_ids = uom_obj.search(cr, uid, [('name', '=', uom_name)], context=context)438 uom_ids = uom_obj.search(cr, uid, [('name', '=', uom_name)], context=context)
420 if not uom_ids:439 if not uom_ids:
421 uom_id = obj_data.get_object_reference(cr, uid, 'msf_doc_import','uom_tbd')[1]440 uom_id = obj_data.get_object_reference(cr, uid, 'msf_doc_import','uom_tbd')[1]
441 error_list_line.append(_("The UoM '%s' was not found.") % uom_name)
422 to_correct_ok = True442 to_correct_ok = True
423 else:443 else:
424 uom_id = uom_ids[0]444 uom_id = uom_ids[0]
425 except Exception:445 except Exception:
426 uom_id = obj_data.get_object_reference(cr, uid, 'msf_doc_import','uom_tbd')[1]446 uom_id = obj_data.get_object_reference(cr, uid, 'msf_doc_import','uom_tbd')[1]
447 error_list_line.append(_("The UoM '%s' was not found.") % p_uom)
427 to_correct_ok = True448 to_correct_ok = True
428 #[utp-129]: check consistency of uom449 #[utp-129]: check consistency of uom
429 # 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 product450 # 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
@@ -504,7 +525,8 @@
504 vals['line_ids'].append((0, 0, to_write))525 vals['line_ids'].append((0, 0, to_write))
505 # in case of lines ignored, we notify the user and create a file with the lines ignored526 # in case of lines ignored, we notify the user and create a file with the lines ignored
506 vals.update({'text_error': _('Lines ignored: %s \n ----------------------\n') % (ignore_lines,) +527 vals.update({'text_error': _('Lines ignored: %s \n ----------------------\n') % (ignore_lines,) +
507 '\n'.join(error_list), 'data': False, 'import_error_ok': False})528 '\n'.join(error_list), 'data': False, 'import_error_ok': False,
529 'file_to_import': False})
508 if line_with_error:530 if line_with_error:
509 file_to_export = self.export_file_with_error(cr, uid, ids, line_with_error=line_with_error)531 file_to_export = self.export_file_with_error(cr, uid, ids, line_with_error=line_with_error)
510 vals.update(file_to_export)532 vals.update(file_to_export)
@@ -520,6 +542,13 @@
520 542
521 return self.log(cr, uid, obj.id, msg_to_return,)543 return self.log(cr, uid, obj.id, msg_to_return,)
522544
545 def clear_error(self, cr, uid, ids, context=None):
546 '''
547 Remove the error list and the file with lines in error
548 '''
549 vals = {'data': False, 'text_error': '', 'import_error_ok': False}
550 return self.write(cr, uid, ids, vals, context=context)
551
523 def check_lines_to_fix(self, cr, uid, ids, context=None):552 def check_lines_to_fix(self, cr, uid, ids, context=None):
524 if isinstance(ids, (int, long)):553 if isinstance(ids, (int, long)):
525 ids = [ids]554 ids = [ids]
526555
=== modified file 'supplier_catalogue/supplier_catalogue_view.xml'
--- supplier_catalogue/supplier_catalogue_view.xml 2013-05-13 13:36:18 +0000
+++ supplier_catalogue/supplier_catalogue_view.xml 2013-11-06 13:03:52 +0000
@@ -45,6 +45,7 @@
45 <button name="check_lines_to_fix" string="Check Lines" icon="gtk-dialog-warning" colspan="1" type="object" />45 <button name="check_lines_to_fix" string="Check Lines" icon="gtk-dialog-warning" colspan="1" type="object" />
46 <field name="filename" invisible="1"/>46 <field name="filename" invisible="1"/>
47 <field name="data" filename="filename" attrs="{'invisible': [('import_error_ok', '=', False)]}"/>47 <field name="data" filename="filename" attrs="{'invisible': [('import_error_ok', '=', False)]}"/>
48 <button name="clear_error" string="Clear errors" icon="gtk-clear" colspan="1" type="object" attrs="{'invisible': [('import_error_ok', '=', False)]}" />
48 <field name="import_error_ok" invisible="1"/>49 <field name="import_error_ok" invisible="1"/>
49 <field name="text_error" colspan="4" attrs="{'invisible': [('import_error_ok', '=', False)]}" nolabel="1"/>50 <field name="text_error" colspan="4" attrs="{'invisible': [('import_error_ok', '=', False)]}" nolabel="1"/>
50 </group>51 </group>

Subscribers

People subscribed via source and target branches