Import Metadata

Beta License: LGPL-3 GetFluvo/addons

Import the original creation and last update user and date of records, the create_uid, create_date, write_uid and write_date fields.

Odoo always sets these fields itself, and drops any value given for them. When data is migrated from another system, the original author and dates are lost. With this module, an administrator can keep them by importing with the write_metadata key in the context.

Table of contents

Use Cases / Context

Migrations often have to keep who created a record and when: the date a customer was created, the author of a note, the history of a document. Odoo does not allow setting these fields, even through an import.

Usage

Import with write_metadata in the context, as a user of the Administration / Settings group, and add any of the create_uid, create_date, write_uid and write_date columns. For example with load() through JSON-RPC or XML-RPC:

models.execute_kw(
    db, uid, password, "res.partner", "load",
    [["name", "create_uid", "create_date"],
     [["Azure Interior", "Marc Demo", "2016-01-02 03:04:05"]]],
    {"context": {"write_metadata": True, "tz": "UTC"}},
)

The user columns accept what any many2one column of an import accepts:

The dates are in the YYYY-MM-DD HH:MM:SS format. Like any date of an import, load() reads them in the timezone of the context, or else of the importing user, and stores them in UTC. Pass "tz": "UTC" in the context to import UTC dates unchanged. Empty cells keep the value Odoo sets.

The context key also works for create() and write() called directly, with user ids or records and datetimes or strings.

Without the context key, or for other users, the columns are ignored as without this module, and the import does not fail.

Odoo posts a created message in the chatter of every new record, with the date of the import and the importing user as author. For historical data, suppress it with one of these context keys of Odoo, next to write_metadata:

Known issues / Roadmap

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits

Authors

  • Fluvo

Other credits

Based on the idea and the write_metadata context key of the import_metadata module of easier_import by Thibault Francois. This is a new implementation.

Maintainers

This module is part of the GetFluvo/addons project on GitHub.

You are welcome to contribute.