Metadata-Version: 2.1
Name: odoo12-addon-pattern-import-export
Version: 12.0.2.0.0
Summary: Pattern for import or export
Home-page: http://www.akretion.com
Author: Akretion, Odoo Community Association (OCA)
Author-email: support@odoo-community.org
License: AGPL-3
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Requires-Python: >=3.5
Requires-Dist: numpy
Requires-Dist: odoo12-addon-base-export-manager
Requires-Dist: odoo12-addon-base-jsonify
Requires-Dist: odoo12-addon-queue-job
Requires-Dist: odoo12-addon-web-notify
Requires-Dist: odoo (<12.1dev,>=12.0a)

=====================
Pattern Import Export
=====================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! This file is generated by oca-gen-addon-readme !!
   !! changes will be overwritten.                   !!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/licence-AGPL--3-blue.png
    :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
    :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-shopinvader%2Fpattern--import--export-lightgray.png?logo=github
    :target: https://github.com/shopinvader/pattern-import-export/tree/12.0/pattern_import_export
    :alt: shopinvader/pattern-import-export

|badge1| |badge2| |badge3| 

This module allows to create some patterns to export records.
A pattern is defined by a list of fields to export.
This module only create a common data structure used to do the real export into the expected format.

The import is also implemented to create or update records.
Fields to update (or create) shouldn't be necessarily into the pattern (but the base model should match).
That means if your pattern only contains the name field, you can also update others fields without updating your pattern.

**Table of contents**

.. contents::
   :local:

Usage
=====

Functionally
~~~~~~~~~~~~
To use this module, you only have to install it (please check python dependencies).

First you have to define a pattern:

1. Go on the Import/Export->Patterns menu;
2. Create your pattern with fields to export.


Do export
---------
On a Tree view, select records to export (or into the Form view) and on the
"action" options, pick the "Export with pattern".
On the new wizard, fill the Export pattern to use and click on the "Export button".

A job is now created and your export will be executed as soon as possible (depending on system charge).

Do import
---------
Once your file is edited, you can upload it to create or update related records.

On a Tree view, select at least one record (not necessarily ones to update) and on the "action" button, select "Import with pattern".
A new wizard is open and select a pattern to do the import.

Into your file, you can add/remove/rename column as you want (with specific format and with existing field's name).

You can also add some fields wo aren't into the pattern and these fields' will be updated.

To be more user-friendly, it's not mandatory to work with ID or XML ID to update existing record.
You can just add "/key" at the end of the column name (without spaces) and the column will become the key (please ensure the field used as key as necessary constraints).

Example of simple update on ``product.product``:
Existing record:

- xml id: "__export__.product1"
- name: "Product 1"
- default_code: "PRD1"

The generated export should be like

+---------------------+-----------+--------------+
| id                  | name      | default_code |
+=====================+===========+==============+
| __export__.product1 | Product 1 | PRD1         |
+---------------------+-----------+--------------+

Updated file

+---------------------+---------------+--------------+
| id                  | name          | default_code |
+=====================+===============+==============+
| __export__.product1 | Product 1-bis | PRD1B        |
+---------------------+---------------+--------------+

Then your record will be updated:

- xml id: "__export__.product1"
- name: "Product 1-bis"
- default_code: "PRD1B"

On the same example, you can also edit more complex fields like relational fields:

- seller_ids:

 - xml id (of the seller/partner): "__export__.partner1"
 - name (seller): Partner 1
 - price: 10

The generated export should be like

+---------------------+-----------+--------------+----------------------+--------------------+
| id                  | name      | default_code | seller_ids|1|name|id | seller_ids|1|price |
+=====================+===========+==============+======================+====================+
| __export__.product1 | Product 1 | PRD1         | __export__.partner1  | 10                 |
+---------------------+-----------+--------------+----------------------+--------------------+

The name (seller) is into this format because seller_ids is a reference to many sellers (so specify the ``|1|``) and the name (seller) is itself a reference to a partner. So we have to specify his ID.

You can also specify a partner reference (who is considered as unique) like this:

+---------------------+-----------+--------------+---------------------------+--------------------+
| id                  | name      | default_code | seller_ids|1|name|ref/key | seller_ids|1|price |
+=====================+===========+==============+===========================+====================+
| __export__.product1 | Product 1 | PRD1         | partner1-ref              | 10                 |
+---------------------+-----------+--------------+---------------------------+--------------------+

So this ``/key`` say that Odoo should search for a ``res.partner`` where the ref is the cell's value.


It's also possible to update a product (for this example) based on the default_code instead of the ID.

+---------------------+-----------+------------------+---------------------------+--------------------+
| id                  | name      | default_code/key | seller_ids|1|name|ref/key | seller_ids|1|price |
+=====================+===========+==================+===========================+====================+
|                     | Product 1 | PRD1             | partner1-ref              | 10                 |
+---------------------+-----------+------------------+---------------------------+--------------------+

So Odoo will search the product with the ``default_code`` and update it.


Technically
~~~~~~~~~~~
Add a new export format
-----------------------
1. Inherit the ``ir.exports`` model.
2. Add your new file format in the selection field ``export_format``;
3. Implements functions ``_export_with_record_<format>`` and ``_read_import_data_<format>``.

Please take care of iterators (``yield``) to avoid loading full file into the system memory.

Known issues / Roadmap
======================

Problems are related to UI. They are also present in base_export_manager dependency. If entering correct data the first time, the problems can be ignored.

The following issues are closely related and stem from the first one:

* Currently, base_export_manager does not support modifying a line's relational fields (a crash occurs if you try it)
* Unticking the "Use tab" boolean should clear the previously selected tab_filter_id
* Changing a line's field should clear the previously selected tab_filter_id

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

Bugs are tracked on `GitHub Issues <https://github.com/shopinvader/pattern-import-export/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/shopinvader/pattern-import-export/issues/new?body=module:%20pattern_import_export%0Aversion:%2012.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
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* Chafique Delli <chafique.delli@akretion.com>
* Sébastien Beau <sebastien.beau@akretion.com>
* François Honoré (ACSONE SA/NV) <francois.honore@acsone.eu>

Maintainers
~~~~~~~~~~~

This module is part of the `shopinvader/pattern-import-export <https://github.com/shopinvader/pattern-import-export/tree/12.0/pattern_import_export>`_ project on GitHub.

You are welcome to contribute.


