Browse Source
Merge pull request #1536 from kittiu/12.0-fix-excel_import_export-iteritems
[12.0][FIX] excel_import_export
pull/1530/merge
Pedro M. Baeza
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
4 additions and
3 deletions
-
excel_import_export/models/xlsx_export.py
-
excel_import_export/wizard/import_xlsx_wizard.py
-
excel_import_export_demo/tests/test_xlsx_import_export.py
|
@ -244,7 +244,7 @@ class XLSXExport(models.AbstractModel): |
|
|
f.write(decoded_data) |
|
|
f.write(decoded_data) |
|
|
f.seek(0) |
|
|
f.seek(0) |
|
|
f.close() |
|
|
f.close() |
|
|
# Workbook created, temp fie removed |
|
|
|
|
|
|
|
|
# Workbook created, temp file removed |
|
|
wb = load_workbook(ftemp) |
|
|
wb = load_workbook(ftemp) |
|
|
os.remove(ftemp) |
|
|
os.remove(ftemp) |
|
|
# Start working with workbook |
|
|
# Start working with workbook |
|
|
|
@ -80,7 +80,7 @@ class ImportXLSXWizard(models.TransientModel): |
|
|
# Context testing |
|
|
# Context testing |
|
|
if self._context.get('template_context', False): |
|
|
if self._context.get('template_context', False): |
|
|
template_context = self._context['template_context'] |
|
|
template_context = self._context['template_context'] |
|
|
for key, value in template_context.iteritems(): |
|
|
|
|
|
|
|
|
for key, value in template_context.items(): |
|
|
if key not in record or \ |
|
|
if key not in record or \ |
|
|
(record._fields[key].type == 'many2one' and |
|
|
(record._fields[key].type == 'many2one' and |
|
|
record[key].id or record[key]) != value: |
|
|
record[key].id or record[key]) != value: |
|
|
|
@ -36,7 +36,8 @@ class TestXLSXImportExport(TestExcelImportExport): |
|
|
'active_id': self.sale_order.id, |
|
|
'active_id': self.sale_order.id, |
|
|
'template_domain': [('res_model', '=', 'sale.order'), |
|
|
'template_domain': [('res_model', '=', 'sale.order'), |
|
|
('fname', '=', 'sale_order.xlsx'), |
|
|
('fname', '=', 'sale_order.xlsx'), |
|
|
('gname', '=', False)], } |
|
|
|
|
|
|
|
|
('gname', '=', False)], |
|
|
|
|
|
'template_context': {'state': 'draft'}, } |
|
|
with Form(self.env['import.xlsx.wizard'].with_context(ctx)) as f: |
|
|
with Form(self.env['import.xlsx.wizard'].with_context(ctx)) as f: |
|
|
f.import_file = self.export_file |
|
|
f.import_file = self.export_file |
|
|
import_wizard = f.save() |
|
|
import_wizard = f.save() |
|
|