Merge lp:~unifield-team/unifield-wm/utp-747 into lp:unifield-wm
- utp-747
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Dev Team | Pending | ||
Review via email: mp+194133@code.launchpad.net |
Commit message
Description of the change
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 | 76 | % if h[1] == 'bool': | 76 | % if h[1] == 'bool': |
6 | 77 | <Data ss:Type="Boolean">${result=='True' and '1' or '0'}</Data> | 77 | <Data ss:Type="Boolean">${result=='True' and '1' or '0'}</Data> |
7 | 78 | % elif h[1] in ('number', 'int', 'float'): | 78 | % elif h[1] in ('number', 'int', 'float'): |
9 | 79 | % if not isinstance(result, bool): | 79 | % if isinstance(result, tuple) and len(result) > 1: |
10 | 80 | <Data ss:Type="${result[1]}">${result[0]}</Data> | ||
11 | 81 | % elif not isinstance(result, bool): | ||
12 | 80 | <Data ss:Type="Number">${result}</Data> | 82 | <Data ss:Type="Number">${result}</Data> |
13 | 81 | % else: | 83 | % else: |
14 | 82 | <Data ss:Type="String"></Data> | 84 | <Data ss:Type="String"></Data> |
15 | 83 | 85 | ||
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 | 35 | from spreadsheet_xml.spreadsheet_xml import SpreadsheetXML | 35 | from spreadsheet_xml.spreadsheet_xml import SpreadsheetXML |
21 | 36 | from spreadsheet_xml.spreadsheet_xml_write import SpreadsheetCreator | 36 | from spreadsheet_xml.spreadsheet_xml_write import SpreadsheetCreator |
22 | 37 | 37 | ||
23 | 38 | _HEADER_TYPE = {type('char'): 'string', | ||
24 | 39 | type(1): 'number', | ||
25 | 40 | type(1.00): 'number', | ||
26 | 41 | type(long(1)): 'number', | ||
27 | 42 | type(now()): 'datetime'} | ||
28 | 43 | |||
29 | 38 | class supplier_catalogue(osv.osv): | 44 | class supplier_catalogue(osv.osv): |
30 | 39 | _name = 'supplier.catalogue' | 45 | _name = 'supplier.catalogue' |
31 | 40 | _description = 'Supplier catalogue' | 46 | _description = 'Supplier catalogue' |
32 | @@ -336,11 +342,23 @@ | |||
33 | 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'), |
34 | 337 | ('Comment', 'string')] | 343 | ('Comment', 'string')] |
35 | 338 | lines_not_imported = [] # list of list | 344 | lines_not_imported = [] # list of list |
36 | 345 | t_dt = type(now()) | ||
37 | 339 | for line in kwargs.get('line_with_error'): | 346 | for line in kwargs.get('line_with_error'): |
38 | 347 | for f in line: | ||
39 | 348 | if type(f) == t_dt: | ||
40 | 349 | new_f = f.strftime('%Y-%m-%dT%H:%M:%S.000') | ||
41 | 350 | line[line.index(f)] = (new_f, 'DateTime') | ||
42 | 351 | elif isinstance(f, str) and columns_header[line.index(f)][1] != 'string': | ||
43 | 352 | try: | ||
44 | 353 | line[line.index(f)] = (float(f), 'Number') | ||
45 | 354 | except: | ||
46 | 355 | line[line.index(f)] = (f, 'String') | ||
47 | 356 | |||
48 | 340 | if len(line) < len(columns_header): | 357 | if len(line) < len(columns_header): |
49 | 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))]) |
50 | 342 | else: | 359 | else: |
51 | 343 | lines_not_imported.append(line) | 360 | lines_not_imported.append(line) |
52 | 361 | |||
53 | 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) |
54 | 345 | vals = {'data': base64.encodestring(files_with_error.get_xml(['decode.utf8'])), | 363 | vals = {'data': base64.encodestring(files_with_error.get_xml(['decode.utf8'])), |
55 | 346 | 'filename': 'Lines_Not_Imported.xls', | 364 | 'filename': 'Lines_Not_Imported.xls', |
56 | @@ -400,30 +418,33 @@ | |||
57 | 400 | if not code_ids: | 418 | if not code_ids: |
58 | 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] |
59 | 402 | to_correct_ok = True | 420 | to_correct_ok = True |
61 | 403 | error_list_line.append(_("The product was not found.")) | 421 | error_list_line.append(_("The product '%s' was not found.") % product_code) |
62 | 404 | else: | 422 | else: |
63 | 405 | default_code = code_ids[0] | 423 | default_code = code_ids[0] |
64 | 406 | except Exception: | 424 | except Exception: |
65 | 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] |
66 | 408 | to_correct_ok = True | 426 | to_correct_ok = True |
68 | 409 | error_list_line.append(_("The product was not found.")) | 427 | error_list_line.append(_("The product '%s' was not found.") % product_code) |
69 | 410 | 428 | ||
70 | 411 | #Product UoM | 429 | #Product UoM |
71 | 412 | p_uom = len(row.cells)>=3 and row.cells[2].data | 430 | p_uom = len(row.cells)>=3 and row.cells[2].data |
72 | 413 | if not p_uom: | 431 | if not p_uom: |
73 | 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] |
74 | 415 | to_correct_ok = True | 433 | to_correct_ok = True |
75 | 434 | error_list_line.append(_("The UoM '%s' was not found.") % p_uom) | ||
76 | 416 | else: | 435 | else: |
77 | 417 | try: | 436 | try: |
78 | 418 | uom_name = p_uom.strip() | 437 | uom_name = p_uom.strip() |
79 | 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) |
80 | 420 | if not uom_ids: | 439 | if not uom_ids: |
81 | 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] |
82 | 441 | error_list_line.append(_("The UoM '%s' was not found.") % uom_name) | ||
83 | 422 | to_correct_ok = True | 442 | to_correct_ok = True |
84 | 423 | else: | 443 | else: |
85 | 424 | uom_id = uom_ids[0] | 444 | uom_id = uom_ids[0] |
86 | 425 | except Exception: | 445 | except Exception: |
87 | 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] |
88 | 447 | error_list_line.append(_("The UoM '%s' was not found.") % p_uom) | ||
89 | 427 | to_correct_ok = True | 448 | to_correct_ok = True |
90 | 428 | #[utp-129]: check consistency of uom | 449 | #[utp-129]: check consistency of uom |
91 | 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 product | 450 | # 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 | 504 | vals['line_ids'].append((0, 0, to_write)) | 525 | vals['line_ids'].append((0, 0, to_write)) |
94 | 505 | # in case of lines ignored, we notify the user and create a file with the lines ignored | 526 | # in case of lines ignored, we notify the user and create a file with the lines ignored |
95 | 506 | vals.update({'text_error': _('Lines ignored: %s \n ----------------------\n') % (ignore_lines,) + | 527 | vals.update({'text_error': _('Lines ignored: %s \n ----------------------\n') % (ignore_lines,) + |
97 | 507 | '\n'.join(error_list), 'data': False, 'import_error_ok': False}) | 528 | '\n'.join(error_list), 'data': False, 'import_error_ok': False, |
98 | 529 | 'file_to_import': False}) | ||
99 | 508 | if line_with_error: | 530 | if line_with_error: |
100 | 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) |
101 | 510 | vals.update(file_to_export) | 532 | vals.update(file_to_export) |
102 | @@ -520,6 +542,13 @@ | |||
103 | 520 | 542 | ||
104 | 521 | return self.log(cr, uid, obj.id, msg_to_return,) | 543 | return self.log(cr, uid, obj.id, msg_to_return,) |
105 | 522 | 544 | ||
106 | 545 | def clear_error(self, cr, uid, ids, context=None): | ||
107 | 546 | ''' | ||
108 | 547 | Remove the error list and the file with lines in error | ||
109 | 548 | ''' | ||
110 | 549 | vals = {'data': False, 'text_error': '', 'import_error_ok': False} | ||
111 | 550 | return self.write(cr, uid, ids, vals, context=context) | ||
112 | 551 | |||
113 | 523 | def check_lines_to_fix(self, cr, uid, ids, context=None): | 552 | def check_lines_to_fix(self, cr, uid, ids, context=None): |
114 | 524 | if isinstance(ids, (int, long)): | 553 | if isinstance(ids, (int, long)): |
115 | 525 | ids = [ids] | 554 | ids = [ids] |
116 | 526 | 555 | ||
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 | 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" /> |
122 | 46 | <field name="filename" invisible="1"/> | 46 | <field name="filename" invisible="1"/> |
123 | 47 | <field name="data" filename="filename" attrs="{'invisible': [('import_error_ok', '=', False)]}"/> | 47 | <field name="data" filename="filename" attrs="{'invisible': [('import_error_ok', '=', False)]}"/> |
124 | 48 | <button name="clear_error" string="Clear errors" icon="gtk-clear" colspan="1" type="object" attrs="{'invisible': [('import_error_ok', '=', False)]}" /> | ||
125 | 48 | <field name="import_error_ok" invisible="1"/> | 49 | <field name="import_error_ok" invisible="1"/> |
126 | 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"/> |
127 | 50 | </group> | 51 | </group> |