Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b06ee7a
[ADD] base_import_odoo
hbrunn Sep 17, 2017
98b1232
[ADD] allow mapping records by equal field values
hbrunn Oct 11, 2017
a9707ae
[FIX] support firefox
hbrunn Oct 11, 2017
9b8e6cf
[IMP] community review
hbrunn Oct 11, 2017
a740acb
[RFR] use odoorpc
hbrunn Oct 12, 2017
8f8776b
[ADD] make it possible to import res_model,res_id references
hbrunn Oct 12, 2017
d7b6e92
[IMP] disable recomputation during import
hbrunn Oct 12, 2017
ce060ab
[ADD] better progress
hbrunn Oct 12, 2017
e6e1b98
Revert "[IMP] disable recomputation during import"
hbrunn Oct 12, 2017
3d0736f
[ADD] more tests
hbrunn Oct 12, 2017
2f9e747
[FIX] dummy cleanup
hbrunn Oct 13, 2017
0ef4f2a
[ADD] depend on mail
hbrunn Oct 17, 2017
0d1ff43
[ADD] fix when running tests with accounting
hbrunn Oct 19, 2017
2f8d739
[ADD] duplicate treatment
hbrunn Oct 19, 2017
26158e3
[FIX] don't pass an empty string for required char fields
hbrunn Oct 25, 2017
6dbc589
OCA Transbot updated translations from Transifex
oca-transbot Oct 28, 2017
83829f2
[FIX] Be less alarming about missing library (Module does not have to…
StefanRijnhart Jan 16, 2018
626c4b0
Bump base_import_odoo version
yvaucher Jan 31, 2018
1f1c1c8
[ADD] create an xmlid for mapped records too (#1059)
hbrunn Mar 30, 2018
c9fcab9
[ADD] [base_import_odoo] don't write falsy values on required fields
hbrunn Jun 20, 2018
0b45e56
[MIG] base_import_odoo
hbrunn Jul 19, 2018
628d585
[UPD] Update base_import_odoo.pot
oca-travis Jul 8, 2019
8de465d
Update translation files
oca-transbot Jul 20, 2019
34684f6
Update translation files
oca-transbot Aug 16, 2020
9bdebd3
[IMP] base_import_odoo: black, isort, prettier
hbrunn Dec 7, 2020
919f7f6
[MIG] base_import_odoo: Migration to v13
hbrunn Dec 7, 2020
6eb7c7d
[ADD] possibility to keep passwords
hbrunn Dec 15, 2020
54f6ae3
[FIX] don't scope xmlids with the module's name to avoid issues on un…
hbrunn Jan 9, 2023
93ba560
[ADD] pre-commit
hbrunn Jan 17, 2023
b285bea
[IMP] default to 'id asc' to create records in the same order as they…
Jan 20, 2023
1f5ad61
[UPD] for a reference id field, also allow many2one_reference, not on…
Jan 20, 2023
5d750d7
[IMP] dont try to query fields that dont exist remotely
Jan 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions base_import_odoo/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
================
Import from Odoo
================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-OCA%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/13.0/base_import_odoo
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-base_import_odoo
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/149/13.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module was written to import data from another Odoo database. The idea is that you define which models to import from the other database, and add eventual mappings for records you don't want to import.

Use cases
=========

- merging databases
- one way sync
- aggregating management data from distributed systems

**Table of contents**

.. contents::
:local:

Configuration
=============

Go to Settings / Remote Odoo import / Import configurations and create a configuration.

After filling in your credentials, select models you want to import from the remote database. If you only want to import a subset of the records, add an appropriate domain.

The import will copy records of all models listed, and handle links to records of models which are not imported depending on the existing field mappings. Field mappings to local records also are a stopping condition. Without those, the import will have to create some record for all required x2x fields, which you probably don't want.

Probably you'll want to map records of model ``res.company``, and at least the admin user.

The module doesn't import one2many fields, if you want to have those, add the model the field in question points to to the list of imported models, possibly with a domain.

If you don't fill in a remote ID, the addon will use the configured local ID for every record of the model (this way, you can for example map all users in the remote system to some import user in the current system).

For fields that have a uniqueness constraint (like ``res.users#login``), create a field mapping if type ``unique``, then the import will generate a unique value for this field.

For models using references with two fields (like ``ir.attachment``), create a field mapping of type ``by reference`` and select the two fields involved. The import will transform known ids (=ids of models you import) to the respective local id, and clean out the model/id fields for unknown models/ids.

You can add custom defaults per model in case your database has different required fields than the source database. For ``res.partner``, you'll most certainly fill in ``{'name': '/'}`` or somethign similar.

Usage
=====

To use this module, you need to:

#. go to an import configuration and hit the button ``Run import``
#. be patient, this creates a cronjob which will start up to a minutes afterwards
#. reload the form, as soon as the cronjob runs you'll see a field ``Progress`` that lets you inspect what was imported already
#. note that the cronjob also resets the password as soon as it has read it. So for a subsequent import, you'll have to fill it in again
#. running an import a second time won't duplicate data, it should recognize records imported earlier and just update them

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

* Yes of course this duplicates a lot of connector functionality. Rewrite this with the connector framework, probably collaborate with https://github.com/OCA/connector-odoo2odoo
* Support reference fields, while being at it refactor _run_import_map_values to call a function per field type
* Add duplicate handling strategy 'Overwrite older'

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/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/OCA/server-tools/issues/new?body=module:%20base_import_odoo%0Aversion:%2013.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
~~~~~~~

* Therp BV
* Hunki Enterprises BV

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

* Holger Brunn <mail@hunki-enterprises.com>

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

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/13.0/base_import_odoo>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions base_import_odoo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2017-2018 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
29 changes: 29 additions & 0 deletions base_import_odoo/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# (c) 2017-2018 Therp BV <http://therp.nl>
# (c) 2020 Hunki Enterprises BV <https://hunki-enterprises.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Import from Odoo",
"version": "13.0.1.0.0",
"author": "Therp BV,Hunki Enterprises BV,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Tools",
"summary": "Import records from another Odoo instance",
"website": "https://github.com/OCA/server-tools",
"depends": ["mail", "base_sparse_field"],
"demo": [
"demo/res_partner.xml",
"demo/res_users.xml",
"demo/ir_attachment.xml",
"demo/import_odoo_database.xml",
"demo/import_odoo_database_field.xml",
"demo/import_odoo_database_model.xml",
],
"data": [
"views/import_odoo_database_field.xml",
"security/ir.model.access.csv",
"views/import_odoo_database.xml",
"views/menu.xml",
],
"installable": True,
"external_dependencies": {"python": ["odoorpc"]},
}
9 changes: 9 additions & 0 deletions base_import_odoo/demo/import_odoo_database.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<record id="demodb" model="import.odoo.database">
<field name="url">http://localhost:8069</field>
<field name="database">demodb</field>
<field name="user">admin</field>
<field name="password" eval="False" />
</record>
</odoo>
70 changes: 70 additions & 0 deletions base_import_odoo/demo/import_odoo_database_field.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<record id="mapping_partner_id_admin" model="import.odoo.database.field">
<field name="database_id" ref="demodb" />
<field name="mapping_type">fixed</field>
<field name="model_id" ref="base.model_res_partner" />
<field name="local_id" ref="base.partner_admin" />
<field name="remote_id" ref="base.partner_admin" />
</record>
<record id="mapping_partner_id_company" model="import.odoo.database.field">
<field name="database_id" ref="demodb" />
<field name="mapping_type">fixed</field>
<field name="model_id" ref="base.model_res_partner" />
<field name="local_id" ref="base.main_partner" />
<field name="remote_id" ref="base.main_partner" />
</record>
<record id="mapping_partner_id_root" model="import.odoo.database.field">
<field name="database_id" ref="demodb" />
<field name="mapping_type">fixed</field>
<field name="model_id" ref="base.model_res_partner" />
<field name="local_id" ref="base.partner_root" />
<field name="remote_id" ref="base.partner_root" />
</record>
<record id="mapping_user_admin" model="import.odoo.database.field">
<field name="database_id" ref="demodb" />
<field name="mapping_type">fixed</field>
<field name="model_id" ref="base.model_res_users" />
<field name="local_id" ref="mapped_admin" />
<field name="remote_id" ref="base.user_admin" />
</record>
<record id="mapping_user_root" model="import.odoo.database.field">
<field name="database_id" ref="demodb" />
<field name="mapping_type">fixed</field>
<field name="model_id" ref="base.model_res_users" />
<field name="local_id" ref="base.user_root" />
<field name="remote_id" ref="base.user_root" />
</record>
<record id="mapping_company_id" model="import.odoo.database.field">
<field name="database_id" ref="demodb" />
<field name="mapping_type">fixed</field>
<field name="model_id" ref="base.model_res_company" />
<field name="local_id" ref="base.main_company" />
<field name="remote_id" ref="base.main_company" />
</record>
<record id="mapping_login" model="import.odoo.database.field">
<field name="database_id" ref="demodb" />
<field name="mapping_type">unique</field>
<field name="model_id" ref="base.model_res_users" />
<field name="field_ids" eval="[(4, ref('base.field_res_users__login'))]" />
</record>
<record id="mapping_models" model="import.odoo.database.field">
<field name="database_id" ref="demodb" />
<field name="mapping_type">by_field</field>
<field name="model_id" ref="base.model_ir_model" />
<field name="field_ids" eval="[(4, ref('base.field_ir_model__name'))]" />
</record>
<record id="mapping_groups" model="import.odoo.database.field">
<field name="database_id" ref="demodb" />
<field name="mapping_type">by_field</field>
<field name="model_id" ref="base.model_res_groups" />
<field name="field_ids" eval="[(4, ref('base.field_res_groups__name'))]" />
</record>
<record id="mapping_attachment" model="import.odoo.database.field">
<field name="database_id" ref="demodb" />
<field name="mapping_type">by_reference</field>
<field name="model_id" ref="base.model_ir_attachment" />
<field name="model_field_id" ref="base.field_ir_attachment__res_model" />
<field name="id_field_id" ref="base.field_ir_attachment__res_id" />
</record>
</odoo>
34 changes: 34 additions & 0 deletions base_import_odoo/demo/import_odoo_database_model.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<record id="model_partner" model="import.odoo.database.model">
<field name="sequence">1</field>
<field name="model_id" ref="base.model_res_partner" />
<field name="database_id" ref="demodb" />
<field name="domain">[(1, '=', 1)]</field>
<field name="defaults">{'name': '/'}</field>
</record>
<record id="model_alias" model="import.odoo.database.model">
<field name="sequence">2</field>
<field name="model_id" ref="mail.model_mail_alias" />
<field name="database_id" ref="demodb" />
<field name="domain">[(1, '=', 1)]</field>
</record>
<record id="model_users" model="import.odoo.database.model">
<field name="sequence">3</field>
<field name="model_id" ref="base.model_res_users" />
<field name="database_id" ref="demodb" />
<field name="domain">[(1, '=', 1)]</field>
</record>
<record id="model_groups" model="import.odoo.database.model">
<field name="sequence">4</field>
<field name="model_id" ref="base.model_res_groups" />
<field name="database_id" ref="demodb" />
<field name="domain">[(1, '=', 1)]</field>
</record>
<record id="model_attachment" model="import.odoo.database.model">
<field name="sequence">5</field>
<field name="model_id" ref="base.model_ir_attachment" />
<field name="database_id" ref="demodb" />
<field name="domain">[('res_model', 'in', ['res.users'])]</field>
</record>
</odoo>
9 changes: 9 additions & 0 deletions base_import_odoo/demo/ir_attachment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="attachment_demo" model="ir.attachment">
<field name="name">Demo attachment</field>
<field name="res_model">res.users</field>
<field name="res_id" ref="base.user_demo" />
<field name="datas">aGVsbG8gd29ybGQK</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions base_import_odoo/demo/res_partner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="base.res_partner_1" model="res.partner">
<field name="user_id" ref="base.user_demo" />
</record>
</odoo>
7 changes: 7 additions & 0 deletions base_import_odoo/demo/res_users.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<record id="mapped_admin" model="res.users" context="{'no_reset_password': True}">
<field name="name">Mapped admin</field>
<field name="login">mapped_admin</field>
</record>
</odoo>
Loading