Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
128 changes: 128 additions & 0 deletions base_import_match/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

=================
Base Import Match
=================

By default, when importing data (like CSV import) with the ``base_import``
module, Odoo follows this rule:

- If you import the XMLID of a record, make an **update**.
- If you do not, **create** a new record.

This module allows you to set additional rules to match if a given import is an
update or a new record.

This is useful when you need to sync heterogeneous databases, and the field you
use to match records in those databases with Odoo's is not the XMLID but the
name, VAT, email, etc.

After installing this module, the import logic will be changed to:

- If you import the XMLID of a record, make an **update**.
- If you do not:

- If there are import match rules for the model you are importing:

- Discard the rules that require fields you are not importing.
- Traverse the remaining rules one by one in order to find a match in the database.

- Skip the rule if it requires a special condition that is not
satisfied.
- If one match is found:

- Stop traversing the rest of valid rules.
- **Update** that record.
- If zero or multiple matches are found:

- Continue with the next rule.
- If all rules are exhausted and no single match is found:

- **Create** a new record.
- If there are no match rules for your model:

- **Create** a new record.

By default 2 rules are installed for production instances:

- One rule that will allow you to update companies based on their VAT, when
``is_company`` is ``True``.
- One rule that will allow you to update users based on their login.

In demo instances there are more examples.

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

To configure this module, you need to:

#. Go to *Settings > Technical > Database Structure > Import Match*.
#. *Create*.
#. Choose a *Model*.
#. Choose the *Fields* that conform an unique key in that model.
#. If the rule must be used only for certain imported values, check
*Conditional* and enter the **exact string** that is going to be imported
in *Imported value*.

#. Keep in mind that the match here is evaluated as a case sensitive
**text string** always. If you enter e.g. ``True``, it will match that
string, but will not match ``1`` or ``true``.
#. *Save*.

In that list view, you can sort rules by drag and drop.

Usage
=====

To use this module, you need to:

#. Follow steps in **Configuration** section above.
#. Go to any list view.
#. Press *Import* and follow the import procedure as usual.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/149/8.0

Known Issues / Roadmap
======================

* Add a setting to throw an error when multiple matches are found, instead of
falling back to creation of new record.

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:%20
base_import_match%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======

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

* Jairo Llopis <yajo.sk8@gmail.com>

Maintainer
----------

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

This module is maintained by the OCA.

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.

To contribute to this module, please visit https://odoo-community.org.
5 changes: 5 additions & 0 deletions base_import_match/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
26 changes: 26 additions & 0 deletions base_import_match/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# © 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Base Import Match",
"summary": "Try to avoid duplicates before importing",
"version": "9.0.1.0.0",
"category": "Tools",
"website": "https://grupoesoc.es",
"author": "Grupo ESOC Ingeniería de Servicios, "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": [
"base_import",
],
"data": [
"security/ir.model.access.csv",
"views/base_import_match_view.xml",
"data/base_import_match.yml",
],
"demo": [
"demo/base_import_match.yml",
],
"application": False,
"installable": True,
}
29 changes: 29 additions & 0 deletions base_import_match/data/base_import_match.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# © 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

- !context {noupdate: True}

# Match partners by VAT when is_company is True
- !record {id: res_partner_vat, model: base_import.match}:
model_id: base.model_res_partner
sequence: 10

- !record {id: res_partner_vat_vat, model: base_import.match.field}:
match_id: res_partner_vat
field_id: base.field_res_partner_vat

- !record {id: res_partner_vat_is_company, model: base_import.match.field}:
match_id: res_partner_vat
field_id: base.field_res_partner_is_company
conditional: True
imported_value: "True"

# Match users by login
- !record {id: res_users_login, model: base_import.match}:
model_id: base.model_res_users
sequence: 50

- !record {id: res_users_login_login, model: base_import.match.field}:
match_id: res_users_login
field_id: base.field_res_users_login
40 changes: 40 additions & 0 deletions base_import_match/demo/base_import_match.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
# © 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

- !context {noupdate: True}

# Match partners by name, parent_id and is_company
- !record {id: res_partner_parent_name_is_company, model: base_import.match}:
model_id: base.model_res_partner
sequence: 20

- !record {id: res_partner_parent_name_is_company_name, model: base_import.match.field}:
match_id: res_partner_parent_name_is_company
field_id: base.field_res_partner_name

- !record {id: res_partner_parent_name_is_company_parent, model: base_import.match.field}:
match_id: res_partner_parent_name_is_company
field_id: base.field_res_partner_parent_id

- !record {id: res_partner_parent_name_is_company_is_company, model: base_import.match.field}:
match_id: res_partner_parent_name_is_company
field_id: base.field_res_partner_is_company

# Match partner by email
- !record {id: res_partner_email, model: base_import.match}:
model_id: base.model_res_partner
sequence: 30

- !record {id: res_partner_email_email, model: base_import.match.field}:
match_id: res_partner_email
field_id: base.field_res_partner_email

# Match partner by name
- !record {id: res_partner_name, model: base_import.match}:
model_id: base.model_res_partner
sequence: 40

- !record {id: res_partner_name_name, model: base_import.match.field}:
match_id: res_partner_name
field_id: base.field_res_partner_name
154 changes: 154 additions & 0 deletions base_import_match/i18n/am.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_import_match
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: server-tools (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-09-16 09:29+0000\n"
"PO-Revision-Date: 2016-05-27 15:24+0000\n"
"Last-Translator: <>\n"
"Language-Team: Amharic (http://www.transifex.com/oca/OCA-server-tools-8-0/language/am/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: am\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#. module: base_import_match
#: field:base_import.match.field,conditional:0
msgid "Conditional"
msgstr ""

#. module: base_import_match
#: field:base_import.match,create_uid:0
#: field:base_import.match.field,create_uid:0
msgid "Created by"
msgstr "Creado por"

#. module: base_import_match
#: field:base_import.match,create_date:0
#: field:base_import.match.field,create_date:0
msgid "Created on"
msgstr "Creado en"

#. module: base_import_match
#: model:ir.model,name:base_import_match.model_base_import_match
msgid "Deduplicate settings prior to CSV imports."
msgstr ""

#. module: base_import_match
#: field:base_import.match,display_name:0
#: field:base_import.match.field,display_name:0
msgid "Display Name"
msgstr ""

#. module: base_import_match
#: help:base_import.match.field,conditional:0
msgid "Enable if you want to use this field only in some conditions."
msgstr ""

#. module: base_import_match
#: field:base_import.match.field,field_id:0
msgid "Field"
msgstr ""

#. module: base_import_match
#: model:ir.model,name:base_import_match.model_base_import_match_field
msgid "Field import match definition"
msgstr ""

#. module: base_import_match
#: help:base_import.match.field,field_id:0
msgid "Field that will be part of an unique key."
msgstr ""

#. module: base_import_match
#: field:base_import.match,field_ids:0
msgid "Fields"
msgstr ""

#. module: base_import_match
#: help:base_import.match,field_ids:0
msgid "Fields that will define an unique key."
msgstr ""

#. module: base_import_match
#: view:base_import.match:base_import_match.match_search_view
msgid "Group By"
msgstr ""

#. module: base_import_match
#: field:base_import.match,id:0 field:base_import.match.field,id:0
msgid "ID"
msgstr "ID"

#. module: base_import_match
#: help:base_import.match.field,imported_value:0
msgid ""
"If the imported value is not this, the whole matching rule will be "
"discarded. Be careful, this data is always treated as a string, and "
"comparison is case-sensitive so if you set 'True', it will NOT match '1' nor"
" 'true', only EXACTLY 'True'."
msgstr ""

#. module: base_import_match
#: view:base_import.match:base_import_match.match_form_view
#: view:base_import.match:base_import_match.match_search_view
#: view:base_import.match:base_import_match.match_tree_view
#: model:ir.actions.act_window,name:base_import_match.match_action
#: model:ir.ui.menu,name:base_import_match.match_menu
msgid "Import Match"
msgstr ""

#. module: base_import_match
#: field:base_import.match.field,imported_value:0
msgid "Imported value"
msgstr ""

#. module: base_import_match
#: help:base_import.match,model_id:0 help:base_import.match.field,model_id:0
msgid "In this model you will apply the match."
msgstr ""

#. module: base_import_match
#: field:base_import.match,__last_update:0
#: field:base_import.match.field,__last_update:0
msgid "Last Modified on"
msgstr ""

#. module: base_import_match
#: field:base_import.match,write_uid:0
#: field:base_import.match.field,write_uid:0
msgid "Last Updated by"
msgstr "Última actualización por"

#. module: base_import_match
#: field:base_import.match,write_date:0
#: field:base_import.match.field,write_date:0
msgid "Last Updated on"
msgstr "Última actualización en"

#. module: base_import_match
#: field:base_import.match.field,match_id:0
msgid "Match"
msgstr ""

#. module: base_import_match
#: view:base_import.match:base_import_match.match_search_view
#: field:base_import.match,model_id:0 field:base_import.match,model_name:0
#: field:base_import.match.field,model_id:0
msgid "Model"
msgstr ""

#. module: base_import_match
#: field:base_import.match,name:0 field:base_import.match.field,name:0
msgid "Name"
msgstr ""

#. module: base_import_match
#: field:base_import.match,sequence:0
msgid "Sequence"
msgstr ""
Loading