Repository
odoo/odoo · module folder
Module version
2.0
Category
Hidden/Tools
Folder size
2.14 MB
License
LGPL-3
Application
No
Auto-installable
Yes
Website
None
Last tracking update
2026-08-15 22:44:16
Authors
Odoo S.A.
Maintainers
Odoo S.A.
Committers
Xavier Morel, Raphael Collet, Odoo Translation Bot, Denis Ledoux, Aaron Bohy, GitHub, Lucas Perais (lpe), Damien Bouvy, Jorge Pinna Puissant, Julien Castiaux, Romeo Fragomeli, Julien Mougenot, Anh Thao Pham (pta), Rémy Voet (ryv), Tiffany Chang (tic), Gorash, Mathieu Duckerts-Antoine, Pierre Paridans, luvi, Hubert Van De Walle, Renaud Thiry, Levi Siuzdak (sile), Dylan Kiss (dyki), sesn-odoo, Walid (wasa), lase@odoo.com, Ethan Vincent, jorv-odoo, Julien Carion (juca), kcv-odoo, Michaël Mattiello, pish-odoo, Krzysztof Magusiak (krma), bhna-odoo, Saurabh, Elliot ELCO, YoussefM890, saurabh
Odoo dependencies
odoo/odoo:
- web
Python dependencies
None
System dependencies
None
Required by
base_import_async, test_import_export
Description
New extensible file import for Odoo
======================================

Re-implement Odoo's file import system:

* Server side, the previous system forces most of the logic into the
  client which duplicates the effort (between clients), makes the
  import system much harder to use without a client (direct RPC or
  other forms of automation) and makes knowledge about the
  import/export system much harder to gather as it is spread over
  3+ different projects.

* In a more extensible manner, so users and partners can build their
  own front-end to import from other file formats (e.g. OpenDocument
  files) which may be simpler to handle in their work flow or from
  their data production sources.

* In a module, so that administrators and users of Odoo who do not
  need or want an online import can avoid it being available to users.

Code Analysis

Views touched (0)

No views found for this module.

HTTP endpoints (1)
Route(s)HandlerAuthTypeMethodsFlags
/base_import/set_file ImportController.set_file user http POST
Models touched (4)

New fields (0)

No new fields.

Public methods (1)
  • get_import_templates(self)
    @api.model
    Get the import templates label and path. :return: a list(dict) containing label and template path like ``[{'label': 'foo', 'template': 'path'}]``

New fields (4)
  • file Binary
    attachment=False help='File to check and/or import, raw binary (not base64)' args: 'File'
  • file_name Char
    args: 'File Name'
  • file_type Char
    args: 'File Type'
  • res_model Char
    args: 'Model'
Public methods (3)
  • execute_import(self, fields, columns, options, dryrun=False)
    Actual execution of the import :param fields: import mapping: maps each column to a field, ``False`` for the columns to ignore :type fields: list(str|bool) :param columns: columns label :type columns: list(str|bool) :param dict options: :param bool dryrun: performs all import operations (and validations) but rollbacks writes, allows getting as much errors as possible without the risk of clobbering the database. :returns: A list of errors. If the list is empty the import executed fully and correctly. If the list is non-empty it contains dicts with 3 keys: ``type`` the type of error (``error|warning``) ``message`` the error message associated with the error (a string) ``record`` the data which failed to import (or ``false`` if that data isn't available or provided) :rtype: dict(ids: list(int), messages: list({type, message, record}))
  • get_fields_tree(self, model, depth=FIELDS_RECURSION_LIMIT)
    @api.model
    Recursively get fields for the provided model (through fields_get) and filter them according to importability The output format is a list of :class:`Field`: .. class:: Field .. attribute:: id: str A non-unique identifier for the field, used to compute the span of the ``required`` attribute: if multiple ``required`` fields have the same id, only one of them is necessary. .. attribute:: name: str The field's logical (Odoo) name within the scope of its parent. .. attribute:: string: str The field's human-readable name (``@string``) .. attribute:: required: bool Whether the field is marked as required in the model. Clients must provide non-empty import values for all required fields or the import will error out. .. attribute:: fields: list[Field] The current field's subfields. The database and external identifiers for m2o and m2m fields; a filtered and transformed fields_get for o2m fields (to a variable depth defined by ``depth``). Fields with no sub-fields will have an empty list of sub-fields. .. attribute:: model_name: str Used in the Odoo Field Tooltip on the import view and to get the model of the field of the related field(s). Name of the current field's model. .. attribute:: comodel_name: str Used in the Odoo Field Tooltip on the import view and to get the model of the field of the related field(s). Name of the current field's comodel, i.e. if the field is a relation field. Structure example for 'crm.team' model for returned importable_fields:: [ {'name': 'message_ids', 'string': 'Messages', 'model_name': 'crm.team', 'comodel_name': 'mail.message', 'fields': [ {'name': 'moderation_status', 'string': 'Moderation Status', 'model_name': 'mail.message', 'fields': []}, {'name': 'body', 'string': 'Contents', 'model_name': 'mail.message', 'fields' : []} ]}, {{'name': 'name', 'string': 'Sales Team', 'model_name': 'crm.team', 'fields' : []} ] :param str model: name of the model to get fields form :param int depth: depth of recursion into o2m fields
  • parse_preview(self, options, count=10)
    Generates a preview of the uploaded files, and performs fields-matching between the import's file data and the model's columns. If the headers are not requested (not options.has_headers), returned ``matches`` and ``headers`` are both ``False``. :param int count: number of preview lines to generate :param options: format-specific options. CSV: {quoting, separator, headers} :type options: {str, str, str, bool} :returns: ``{fields, matches, headers, preview} | {error, preview}`` :rtype: {dict(str: dict(...)), dict(int, list(str)), list(str), list(list(str))} | {str, str}

New fields (3)
  • column_name Char
  • field_name Char
  • res_model Char
    index=True
Public methods (0)

No public methods.

New fields (0)

No new fields.

Public methods (0)

No public methods.

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…