[ADD] error reporting to user during preview
bzr revid: xmo@openerp.com-20120814124835-9nkqni98ie2eyt5r
This commit is contained in:
parent
aec461651e
commit
323b979146
|
@ -27,6 +27,7 @@ Re-implement openerp's file import system:
|
|||
'depends': ['base'],
|
||||
'installable': True,
|
||||
'auto_install': False, # set to true and allow uninstall?
|
||||
'css': ['static/src/css/import.css'],
|
||||
'js': ['static/src/js/import.js'],
|
||||
'qweb': ['static/src/xml/import.xml'],
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ class ir_import(orm.TransientModel):
|
|||
# preview to a list in the return.
|
||||
_logger.debug("Error during CSV parsing preview", exc_info=True)
|
||||
return {
|
||||
'error': _("Failed to parse CSV file: %s") % e,
|
||||
'error': str(e),
|
||||
# iso-8859-1 ensures decoding will always succeed,
|
||||
# even if it yields non-printable characters. This is
|
||||
# in case of UnicodeDecodeError (or csv.Error
|
||||
|
|
|
@ -61,7 +61,7 @@ openerp.base_import = function (instance) {
|
|||
file_update: function (e) {
|
||||
if (!this.$('input.oe_import_file').val()) { return; }
|
||||
|
||||
// TODO: hide preview before calling set_file
|
||||
this.$element.removeClass('oe_import_preview oe_import_error');
|
||||
jsonp(this.$element, {
|
||||
url: '/base_import/set_file'
|
||||
}, this.proxy('file_updated'));
|
||||
|
@ -76,7 +76,15 @@ openerp.base_import = function (instance) {
|
|||
}]).then(this.proxy('preview'));
|
||||
},
|
||||
preview: function (result) {
|
||||
this.$('table').html(QWeb.render('ImportView.preview', result));
|
||||
if (result.error) {
|
||||
this.$element.addClass('oe_import_error');
|
||||
this.$('.oe_import_error_report').html(
|
||||
QWeb.render('ImportView.error', result));
|
||||
} else {
|
||||
this.$element.addClass('oe_import_preview');
|
||||
this.$('table').html(
|
||||
QWeb.render('ImportView.preview', result));
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<templates>
|
||||
<t t-name="ImportView">
|
||||
<form action="" method="post" enctype="multipart/form-data">
|
||||
<form action="" method="post" enctype="multipart/form-data" class="oe_import">
|
||||
<input type="hidden" name="session_id"
|
||||
t-att-value="widget.session.session_id"/>
|
||||
<input type="hidden" name="import_id"/>
|
||||
|
@ -9,6 +9,7 @@
|
|||
|
||||
<table class="oe_import_grid" width="100%">
|
||||
</table>
|
||||
<div class="oe_import_error_report"></div>
|
||||
</form>
|
||||
</t>
|
||||
<!-- TODO: column matcher? -->
|
||||
|
@ -22,4 +23,9 @@
|
|||
><t t-esc="cell"/></td>
|
||||
</tr>
|
||||
</t>
|
||||
<t t-name="ImportView.error">
|
||||
<p>Import preview failed due to: <t t-esc="error"/></p>
|
||||
<p>Here is the start of the file we could not import:</p>
|
||||
<pre><t t-esc="preview"/></pre>
|
||||
</t>
|
||||
</templates>
|
||||
|
|
Loading…
Reference in New Issue