e62320f0c6808fb4cbccaced50ceebcf85e53d8a
6
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
662ecf4e20 |
[IMP] base_import: improve import wizard preview
PURPOSE
Improve import wizard as followup of recent improvements.
SPECIFICATIONS
Preview lines
- make the preview lines more visible
- set font-weight: 500 on o_import_header_name
- remove the text-muted class from the data preview line
- allow the user to preview the first 5 non-empty values
- when hovering on the data preview span, display a tooltip with the first
5 non-empty values of the file column (with 'Preview' as the tooltip title)
- In the 'when a value cannot be matched' dropdown:
add a new 'skip record' option for the following field types: boolean,
many2one, many2many, selection
add a new 'set empty' for the following field types: many2one, many2many,
selection hide this option if the field is required
When a value cannot be matched:
the 'skip record' option will make sure that lines with an unmatched value
will not be imported (i.e. skipped at import)
the 'set empty' option will set the field value to False when the value
cannot be matched
- Restore colored background on alert boxes by removing some css rules
Task-2504343
closes odoo/odoo#73713
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Mohammed Shekha <msh@odoo.com>
|
||
|
|
c483f59b37 |
[REF] base_import: revamp import module
Purpose ======= Propose an import tool that is more intuitive and allows more import options to ease the import. Specifications ============== Update upload import file screen -------------------------------- - Relabel import welcome screen - relabel the 'load file' button to 'upload file' - relabel the first (bold) line of the helper to 'Upload an Excel or CSV file to import' - Move all import options in a left panel - Invert rows and columns in the mapping view - One row for each column (header) to map in the imported file - Columns: File Column / Odoo Field / If a match cannot be found / Comments Left panel details ------------------ The sidepanel to the left of the mapping view is composed as followed: - Imported File - Import file name - Sheet: Dropdown to select the sheet in the file if there are more than 1. - 'use first row as header' checkbox: like the existing option, defines whether the first row of the file should be considered as the header. True by default. If False, display the first value only under 'File Column' (see above) - Formatting: only available if the file is a .csv - list every option that already existed in previous import implementation. - Batch Import - is only available in debug moide and if the file exceeds the batch limit - Batch limit : 2000 - Allow to define the threshold and the batch size. - Help - Download Template link - Go to FAQ link - Advanced - Track history during import. (same as existing functionallity) - Show Fields of relation fields. (same as existing functionallity) Columns details --------------- - File Column: - Contains the column headers of the import file and the first non-empty value of the column as a 'subtitle' (in grey italic) - If 'use first row as header' is False, only display the first column value (without the grey italic) - Odoo Field: - Contains dropdowns to the fields of the current model - Required fields are diplayed in bold in the dropdown - Icon: In the front of the field label, the field type (char, many2one,..) is indicated by an icon. - Tooltip: when hovering a field, display a tooltip with the following information: field label, technical name, type, related model (if any) - Placeholder: If no field is selected, display the placeholder 'To import, select a field...' in text-warning bold (i.e. orange) - Allow clear: there is a close (fa-times) icon at the end of the dropdown body to remove the Odoo field (and prevent import of this column) - Multi Mapping: when setting a field already matched to another column, unset it from the 'old' column (NB: exception made for char/text fields) - Comments: - Contains feedback from the system to the user, either import errors/warnings or any additional details (multi mapping comments,...) - For many2many field, display in related comment cell the following: "To import multiple values, separate them by a comma". - If there is an import error for a specific field, the error will be displayed in the comment cell of the related field. - If there is a mapping error, mapping options are displayed under the error div to let the user choose the best option to fix that error. Import errors management ------------------------ - Errors/warnings that can be matched to a specific field are displayed as alert-danger/warning in the corresponding 'Comments' cell of the field. - For 'no match found' errors, if X values couldn't be found, display an unique error box will all the errors. - Values beyond the first three are folded under a 'More' button. - No changes on the 'See possible values' button. - If an unmatched value is present in one row only, display : '<value> at row X (<name of the row if the name field is matched>)' - If an unmatched value is multiple rows, display: '<value> at multiple rows' - Errors/warnings/infos that cannot be matched to specific field are displayed above the mapping listview. Global errors are not regrouped by error types to avoid too much code complexy just to handle the rare times where multiple errors of same types cannot be linked to a specific mapped field. BaseImportError class have been introduced to ease the formatting of the various exceptions that can occur during the import. After testing the import, display the following above the mapping table: - No warning/error: 'Everything seems valid' (alert-info) - At least one error: 'The file contains blocking errors (see below)' (alert-error) - At least one warning but no error: 'The file contains non-blocking warning (see below)' (alert-warning) Mapping options --------------- Mapping options are only displayed after testing or importing the file, if there are import errors. The goal is to have a clean interface and to guide the user step by step. The import process can therefore be a bit longer as it needs to import -> choose solution for errors -> re-import but that is easier for users to learn and understand this reworked import tool. Possible values when a value cannot be matched: - For many2one / many2many fields: - Prevent import: (selected by default) not finding a match is blocking the import - Skip unknown values: values that cannot be matched will be skipped. (hidden if the field is required) - Create new values: Create records for values that cannot be matched - For selection fields: - Prevent import (selected by default) - Skip unknown values: (hidden if the field is required) - Set to <first value>: if cannot be matched, set it to <first value> - Set to <second value> - Set to <third value> - etc. - For boolean fields: - Prevent Import (selected by default) - Set to True - Set to False Note: With this rework, boolean warnings where the system assumes the replacement value in case of matching error is removed and is replaced by a blocking error. The user now has to choose the value to set. "Prevent import" is the default behaviour when testing or importing. Automatic mapping proposal --------------------------- When loading a file, an automated mapping is directly proposed to the user, based on word distance (see below), and on mapping created on previous imports. - Priority is given for mapping created on previous imports, skip fuzzy mapping. - a distance of -1 is used to ensure priority during duplicates removal . - In case multiple headers are mapped on the same field, if the mapped field is already taken by another header, use fuzzy mapping instead. - If no previous mapping for that header on that model, try an exact match on every field id and field name of the model. (distance = 0) - If no match is found, fuzzy mapping is applied (word distance). The fuzzy mapping is executed only on the most likely fields (see below). - Remove duplicates: keep the header-field couple that has the smallest distance. In case of equality, keep the first. Automatic mapping is therefore optimised for previous mapping or exact match, as fuzzy mapping requires heaviest treatment. This is intended to prioritise the import of files based on import templates. Most likely fields ------------------ When parsing the import file, each header is analysed to guess what type of data the column contains. For example, ff the column contains float, we suppose that that header will most likely be matched on float or monetary fields. The most likely fields are a subset of the model's fields that match the header types. Most likely fields are used for the fuzzy mapping, to propose the user a field mapping based on the header types, if an exact match could not be found. Most likely fields are also listed under "Suggested fields" in the mapping dropdown in "Odoo Field" column of the import tool. For now on, every fields (no mather their type) can be matched to any header, but we prioritise the most likely fields. This way, we don't constrain the mapping possibility based on what we suppose the user would do, but we instead guide suggest the user the most likely mapping solutions. Word distance mapping ---------------------------- In order to improve the mapping configuration, if an exact match cannot be found between the file column and one of the odoo field: - Use Word distance: Word distance return a indice between 0 and 1. - 0: exact match - 1: completely different - A: First try on field['name'] - B: Then on field['string'] - Keep the minimal distance between A and B for each odoo_field - C: Keep the field that has the minimal distance. - Match the column to the field by default if C['distance'] < 0.3. Note: 0.3 has been chosen to ensure proximity but still having a little error margin. Multi mapping ------------- When multiple file columns are matched to the same char/text/many2many field, display the following alert-info box in the "Comments" column of the related fields: "Those columns will be concatenated in field <field label>" Multi mapping rule : - If it is a char field, separate the concatenated values by a space - If it is a text field, separate the concatenated values by a line break - If it is a many2many field, separate the concatenated values by a comma Various improvements -------------------- - During Import (or Test), the first waiting message displayed has been modified to 'Importing...' or 'Testing...'. The progress (x record imported/tested) is only displayed after the first batch of record have been imported/tested. - Ease matching for Selection field: use case insensitive comparaison instead of exact match. - Add filename to import wizard. - Add placeholder to search input of field mapping dropdown. Tests have been adapted accordingly. Links ===== Task ID: 2352241 closes odoo/odoo#61948 Related: odoo/enterprise#17246 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com> |
||
|
|
e12b6013d5 |
[FIX] base_import: tests failing with older chardet
Some distributions still bundle chardet 2.3, which have some guessing
divergences / incompatibilities with python (resolved in 3.x):
1. UTF-{16,32} with BOM is guessed as LE/BE, which when used to decode
the string doesn't strip out the BOM. Handle this by checking if
the BOM is present and converting the encoding name to the
non-marked version in that case.
2. The ISO-8859-1 test string is guessed as ISO-8859-2 (TBF the
decoding does make some sense). Allow multiple targets/guesses to
"fix" that.
closes odoo/odoo#33179
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
|
||
|
|
be96188f2f |
[IMP] base_import: date-parsing patterns
* expand auto-detected date and time patterns (e.g. %b, %I, ...) * try to make date-pattern-detection clearer * add a select2 dropdown for date patterns (with a bunch of preselected patterns) rather than just an input * also try to improve other column-matching bits (e.g. less reliance on exceptions, attempts to avoid redundant work) |
||
|
|
36ee8a78ec |
[IMP] base_import: attempt to automatically guess the separator
It would probably be even better to iterate the file content and get the non-quoted non-alphanumeric characters as separator candidates (instead of a hard-coded list) however Python does not seem to have a decoding iterator (taking bytes and yielding an iterator of codepoints or even grapheme clusters) — incidentally uniseg seems to require up-front decoding as well — so that's not really convenient as we may be dealing with large-ish files and not want to load it entirely in memory. An alternative would be to use TextIOWrapper and iterate the file by buffers of a few ks, and classify that based on either codepoints or grapheme clusters. |
||
|
|
5aba5ac99e |
[IMP] base_import: reintroduce encoding selector & override guess
* if an encoding is explicitly specified, use it and don't guess * otherwise guess and return the guessed encoding so it can be displayed in the configuration UI * fix less-than-stellar configuration & behaviour of select2 inputs to properly reflect underlying values as they get modified, to correctly handle future configuration guesses |