Files
luviandBastien Fafchamps 0566b5f6ba [REF] base_import, web: convert import action to Owl
This commit reimplements the import action view to fully use Owl instead
of its legacy implementation. Different components have been created to
separate the UI in smaller blocks, and a model file contains the main
aspects of the import logic.

The SelectMenu component is now used instead of the jquery select2, and some
other web components and hooks have been used or modified to bring this
action to a better state. A custom ImportBlockUI component is used, to
support custom messages and the use of components. It was required to
reimplement the loading progress and indicator used by the view.

The set_file route in the base_import controller has been adapted to remove
the usage of jsonp type of code for this situation since it is no longer
needed nowadays.

On top of the rewrite, js tests have been added to make sure the feature
behaves correctly, and to assert the intended specs.

Finally, legacy files have been removed, since they are no longer required.

Enterprise PR: https://github.com/odoo/enterprise/pull/34249

task-3092474

Part-of: odoo/odoo#106265
Co-authored-by: Bastien Fafchamps <bafa@odoo.com>
2022-12-23 17:03:37 +01:00

25 lines
678 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import json
from odoo import http
from odoo.http import request
from odoo.tools import misc
class ImportController(http.Controller):
@http.route('/base_import/set_file', methods=['POST'])
# pylint: disable=redefined-builtin
def set_file(self, id):
file = request.httprequest.files.getlist('ufile')[0]
written = request.env['base_import.import'].browse(int(id)).write({
'file': file.read(),
'file_name': file.filename,
'file_type': file.content_type,
})
return json.dumps({'result': written})