Metadata-Version: 2.1
Name: odoo-addon-import_res_id
Version: 20.0.1.0.1
Requires-Dist: odoo==20.0.*
Summary: Link imported messages and attachments to records by XML ID
Home-page: https://github.com/GetFluvo/addons
License: LGPL-3
Author: Fluvo
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 20.0
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
Description-Content-Type: text/x-rst

=============
Import Res ID
=============

.. 
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! This file is generated by oca-gen-addon-readme !!
   !! changes will be overwritten.                   !!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! source digest: sha256:a2e46af534d3d717f9ce869a517e30acc50c9c8de85879c534567ab8392d33a8
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
    :target: https://odoo-community.org/page/development-status
    :alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png
    :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
    :alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-GetFluvo%2Faddons-lightgray.png?logo=github
    :target: https://github.com/GetFluvo/addons/tree/20.0/import_res_id
    :alt: GetFluvo/addons

|badge1| |badge2| |badge3|

Adds a *Document XML ID* field, ``res_external_id``, to messages
(``mail.message``) and attachments (``ir.attachment``), to link them to
their document by the XML ID of that document.

Messages and attachments point to their document with a model name and a
database id, which an import file cannot know. With this field, chatter
messages and attachments can be imported for records imported earlier.

**Table of contents**

.. contents::
   :local:

Use Cases / Context
===================

When migrating to Odoo, the history of the records, the chatter messages
and the attachments, has to be imported too. Without this module the
import file needs the database id of every document, which is only known
after the documents are imported.

Usage
=====

Import messages or attachments with a ``res_external_id`` column holding
the complete XML ID of the document, as ``module.name``. The model and
the id of the document are set from it:

+--------------------------------+--------------+-----------------------+-------------------------+
| body                           | message_type | res_external_id       | attachment_ids/id       |
+================================+==============+=======================+=========================+
| ``<p>Called the customer</p>`` | comment      | ``legacy.partner_42`` | ``legacy.attachment_7`` |
+--------------------------------+--------------+-----------------------+-------------------------+

The field can also be given to ``create()`` and ``write()``, and is
filled in exports with the first XML ID of the document.

- An XML ID that does not exist stops the import with an error, instead
  of creating a message or attachment that is not linked to anything.
- The usual access rights apply to the document. Only administrators can
  move an existing message to another document.
- Import the attachments first, linked to the document with
  ``res_external_id``, then the messages that refer to them with
  ``attachment_ids/id``.

When importing a history, import the documents themselves with
``"mail_create_nolog": True`` or ``"tracking_disable": True`` in the
context, so that Odoo does not add a *created* message of today next to
the imported messages. Messages keep the ``date`` and ``author_id`` of
the import file. To also keep their ``create_uid`` and ``create_date``,
use the ``import_metadata`` module.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/GetFluvo/addons/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 <https://github.com/GetFluvo/addons/issues/new?body=module:%20import_res_id%0Aversion:%2020.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Fluvo

Contributors
------------

- bosd

Other credits
-------------

Based on the idea and the ``res_external_id`` field of the
``import_res_id`` module of
`easier_import <https://github.com/tfrancoi/easier_import>`__ by
Thibault Francois. This is a new implementation.

Maintainers
-----------

This module is part of the `GetFluvo/addons <https://github.com/GetFluvo/addons/tree/20.0/import_res_id>`_ project on GitHub.

You are welcome to contribute.
