[MIG] base_import_match: Migration to 12.0

[UPD] README.rst

[UPD] Update base_import_match.pot
This commit is contained in:
ernesto
2019-02-08 09:26:42 -05:00
committed by anjeel.haria
parent 2c446e0c98
commit fe71d7bdc6
22 changed files with 716 additions and 100 deletions

View File

@@ -1,11 +1,30 @@
.. 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
=================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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--backend-lightgray.png?logo=github
:target: https://github.com/OCA/server-backend/tree/12.0/base_import_match
:alt: OCA/server-backend
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-backend-12-0/server-backend-12-0-base_import_match
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/253/12.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
By default, when importing data (like CSV import) with the ``base_import``
module, Odoo follows this rule:
@@ -53,6 +72,11 @@ By default 2 rules are installed for production instances:
In demo instances there are more examples.
**Table of contents**
.. contents::
:local:
Configuration
=============
@@ -82,11 +106,7 @@ To use this module, you need to:
#. 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/10.0
Known Issues / Roadmap
Known issues / Roadmap
======================
* Add a setting to throw an error when multiple matches are found, instead of
@@ -95,31 +115,42 @@ Known Issues / Roadmap
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.
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-backend/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-backend/issues/new?body=module:%20base_import_match%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
~~~~~~~
* Tecnativa
Contributors
------------
~~~~~~~~~~~~
* Jairo Llopis <yajo.sk8@gmail.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
* `Tecnativa <https://www.tecnativa.com>`_:
* Jairo Llopis
* Vicent Cubells
* Ernesto Tejeda
Maintainer
----------
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. 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.
This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/12.0/base_import_match>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2016 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

View File

@@ -1,15 +1,13 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2016 Tecnativa - Vicent Cubells
# 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": "10.0.1.0.0",
"version": "12.0.1.0.0",
"category": "Tools",
"website": "https://tecnativa.com",
"author": "Grupo ESOC Ingeniería de Servicios,"
"Tecnativa, "
"author": "Tecnativa, "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,

View File

@@ -11,11 +11,11 @@
</record>
<record model="base_import.match.field" id="res_partner_vat_vat">
<field name="match_id" ref="base_import_match.res_partner_vat"/>
<field name="field_id" ref="base.field_res_partner_vat"/>
<field name="field_id" ref="base.field_res_partner__vat"/>
</record>
<record model="base_import.match.field" id="res_partner_vat_is_company">
<field name="match_id" ref="base_import_match.res_partner_vat"/>
<field name="field_id" ref="base.field_res_partner_is_company"/>
<field name="field_id" ref="base.field_res_partner__is_company"/>
<field name="conditional">True</field>
<field name="imported_value">True</field>
</record>
@@ -27,7 +27,7 @@
</record>
<record model="base_import.match.field" id="res_users_login_login">
<field name="match_id" ref="base_import_match.res_users_login"/>
<field name="field_id" ref="base.field_res_users_login"/>
<field name="field_id" ref="base.field_res_users__login"/>
</record>
</odoo>

View File

@@ -11,15 +11,15 @@
</record>
<record model="base_import.match.field" id="res_partner_parent_name_is_company_name">
<field name="match_id" ref="res_partner_parent_name_is_company"/>
<field name="field_id" ref="base.field_res_partner_name"/>
<field name="field_id" ref="base.field_res_partner__name"/>
</record>
<record model="base_import.match.field" id="res_partner_parent_name_is_company_parent">
<field name="match_id" ref="res_partner_parent_name_is_company"/>
<field name="field_id" ref="base.field_res_partner_parent_id"/>
<field name="field_id" ref="base.field_res_partner__parent_id"/>
</record>
<record model="base_import.match.field" id="res_partner_parent_name_is_company_is_company">
<field name="match_id" ref="res_partner_parent_name_is_company"/>
<field name="field_id" ref="base.field_res_partner_is_company"/>
<field name="field_id" ref="base.field_res_partner__is_company"/>
</record>
<!-- Match partner by email -->
@@ -29,7 +29,7 @@
</record>
<record model="base_import.match.field" id="res_partner_email_email">
<field name="match_id" ref="base_import_match.res_partner_email"/>
<field name="field_id" ref="base.field_res_partner_email"/>
<field name="field_id" ref="base.field_res_partner__email"/>
</record>
<!-- Match partner by name -->
@@ -39,7 +39,7 @@
</record>
<record model="base_import.match.field" id="res_partner_name_name">
<field name="match_id" ref="base_import_match.res_partner_name"/>
<field name="field_id" ref="base.field_res_partner_name"/>
<field name="field_id" ref="base.field_res_partner__name"/>
</record>
</odoo>

View File

@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
@@ -14,19 +14,24 @@ msgstr ""
"Plural-Forms: \n"
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field_conditional
#: model:ir.model,name:base_import_match.model_base
msgid "Base"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field__conditional
msgid "Conditional"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_create_uid
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field_create_uid
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match__create_uid
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field__create_uid
msgid "Created by"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_create_date
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field_create_date
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match__create_date
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field__create_date
msgid "Created on"
msgstr ""
@@ -36,23 +41,23 @@ msgid "Deduplicate settings prior to CSV imports."
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_display_name
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field_display_name
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match__display_name
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field__display_name
msgid "Display Name"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,help:base_import_match.field_base_import_match_field_conditional
#: model:ir.model.fields,help:base_import_match.field_base_import_match_field__conditional
msgid "Enable if you want to use this field only in some conditions."
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field_field_id
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field__field_id
msgid "Field"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field_name
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field__name
msgid "Field Name"
msgstr ""
@@ -62,99 +67,98 @@ msgid "Field import match definition"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,help:base_import_match.field_base_import_match_field_field_id
#: model:ir.model.fields,help:base_import_match.field_base_import_match_field__field_id
msgid "Field that will be part of an unique key."
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field_ids
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match__field_ids
msgid "Fields"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,help:base_import_match.field_base_import_match_field_ids
#: model:ir.model.fields,help:base_import_match.field_base_import_match__field_ids
msgid "Fields that will define an unique key."
msgstr ""
#. module: base_import_match
#: model:ir.ui.view,arch_db:base_import_match.match_search_view
#: model_terms:ir.ui.view,arch_db:base_import_match.match_search_view
msgid "Group By"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field_id
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_id
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match__id
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field__id
msgid "ID"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,help:base_import_match.field_base_import_match_field_imported_value
#: model:ir.model.fields,help:base_import_match.field_base_import_match_field__imported_value
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
#: model:ir.actions.act_window,name:base_import_match.match_action
#: model:ir.ui.menu,name:base_import_match.match_menu
#: model:ir.ui.view,arch_db:base_import_match.match_form_view
#: model:ir.ui.view,arch_db:base_import_match.match_search_view
#: model:ir.ui.view,arch_db:base_import_match.match_tree_view
#: model_terms:ir.ui.view,arch_db:base_import_match.match_form_view
#: model_terms:ir.ui.view,arch_db:base_import_match.match_search_view
#: model_terms:ir.ui.view,arch_db:base_import_match.match_tree_view
msgid "Import Match"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field_imported_value
msgid "Imported value"
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field__imported_value
msgid "Imported Value"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,help:base_import_match.field_base_import_match_field_model_id
#: model:ir.model.fields,help:base_import_match.field_base_import_match_model_id
#: model:ir.model.fields,help:base_import_match.field_base_import_match__model_id
#: model:ir.model.fields,help:base_import_match.field_base_import_match_field__model_id
msgid "In this model you will apply the match."
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match___last_update
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field___last_update
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match____last_update
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field____last_update
msgid "Last Modified on"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field_write_uid
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_write_uid
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match__write_uid
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field__write_uid
msgid "Last Updated by"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field_write_date
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_write_date
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match__write_date
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field__write_date
msgid "Last Updated on"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field_match_id
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field__match_id
msgid "Match"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field_model_id
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_model_id
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_model_name
#: model:ir.ui.view,arch_db:base_import_match.match_search_view
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match__model_id
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_field__model_id
#: model_terms:ir.ui.view,arch_db:base_import_match.match_search_view
msgid "Model"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_name
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match__model_name
msgid "Model name"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match__name
msgid "Name"
msgstr ""
#. module: base_import_match
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match_sequence
#: model:ir.model.fields,field_description:base_import_match.field_base_import_match__sequence
msgid "Sequence"
msgstr ""
#. module: base_import_match
#: model:ir.model,name:base_import_match.model_base
msgid "base"
msgstr ""

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2016 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, models
@@ -20,7 +19,8 @@ class Base(models.AbstractModel):
if self.env["base_import.match"]._usable_rules(self._name, fields):
newdata = list()
# Data conversion to ORM format
import_fields = map(models.fix_import_export_id_paths, fields)
import_fields = list(
map(models.fix_import_export_id_paths, fields))
converted_data = self._convert_records(
self._extract_records(import_fields, data))
# Mock Odoo to believe the user is importing the ID field
@@ -44,7 +44,10 @@ class Base(models.AbstractModel):
match = self.env["base_import.match"]._match_find(
self, record, row)
# Give a valid XMLID to this row if a match was found
row["id"] = (match._BaseModel__export_xml_id()
# To generate externals IDS.
match.export_data(fields)
ext_id = match.get_external_id()
row["id"] = (ext_id[match.id]
if match else row.get("id", u""))
# Store the modified row, in the same order as fields
newdata.append(tuple(row[f] for f in clean_fields))

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2016 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@@ -26,6 +25,7 @@ class BaseImportMatch(models.Model):
domain=[("transient", "=", False)],
help="In this model you will apply the match.")
model_name = fields.Char(
string="Model name",
related="model_id.model",
store=True,
index=True)

View File

@@ -0,0 +1,16 @@
To configure this module, you need to:
#. Go to *Settings > Technical > Database Structure > Import Match*.
#. *Create*.
#. Choose a *Model*.
#. Choose the *Fields* that conform a 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.

View File

@@ -0,0 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>`_:
* Jairo Llopis
* Vicent Cubells
* Ernesto Tejeda

View File

@@ -0,0 +1,46 @@
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.

View File

@@ -0,0 +1,2 @@
* Add a setting to throw an error when multiple matches are found, instead of
falling back to creation of new record.

View File

@@ -0,0 +1,5 @@
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.

View File

@@ -0,0 +1,511 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>Base Import Match</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="base-import-match">
<h1 class="title">Base Import Match</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-backend/tree/12.0/base_import_match"><img alt="OCA/server-backend" src="https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-backend-12-0/server-backend-12-0-base_import_match"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/253/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>By default, when importing data (like CSV import) with the <tt class="docutils literal">base_import</tt>
module, Odoo follows this rule:</p>
<ul class="simple">
<li>If you import the XMLID of a record, make an <strong>update</strong>.</li>
<li>If you do not, <strong>create</strong> a new record.</li>
</ul>
<p>This module allows you to set additional rules to match if a given import is an
update or a new record.</p>
<p>This is useful when you need to sync heterogeneous databases, and the field you
use to match records in those databases with Odoos is not the XMLID but the
name, VAT, email, etc.</p>
<p>After installing this module, the import logic will be changed to:</p>
<ul class="simple">
<li>If you import the XMLID of a record, make an <strong>update</strong>.</li>
<li>If you do not:<ul>
<li>If there are import match rules for the model you are importing:<ul>
<li>Discard the rules that require fields you are not importing.</li>
<li>Traverse the remaining rules one by one in order to find a match in the database.<ul>
<li>Skip the rule if it requires a special condition that is not
satisfied.</li>
<li>If one match is found:<ul>
<li>Stop traversing the rest of valid rules.</li>
<li><strong>Update</strong> that record.</li>
</ul>
</li>
<li>If zero or multiple matches are found:<ul>
<li>Continue with the next rule.</li>
</ul>
</li>
<li>If all rules are exhausted and no single match is found:<ul>
<li><strong>Create</strong> a new record.</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>If there are no match rules for your model:<ul>
<li><strong>Create</strong> a new record.</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>By default 2 rules are installed for production instances:</p>
<ul class="simple">
<li>One rule that will allow you to update companies based on their VAT, when
<tt class="docutils literal">is_company</tt> is <tt class="docutils literal">True</tt>.</li>
<li>One rule that will allow you to update users based on their login.</li>
</ul>
<p>In demo instances there are more examples.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id8">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p>To configure this module, you need to:</p>
<ol class="arabic simple">
<li>Go to <em>Settings &gt; Technical &gt; Database Structure &gt; Import Match</em>.</li>
<li><em>Create</em>.</li>
<li>Choose a <em>Model</em>.</li>
<li>Choose the <em>Fields</em> that conform a unique key in that model.</li>
<li>If the rule must be used only for certain imported values, check
<em>Conditional</em> and enter the <strong>exact string</strong> that is going to be imported
in <em>Imported value</em>.<ol class="arabic">
<li>Keep in mind that the match here is evaluated as a case sensitive
<strong>text string</strong> always. If you enter e.g. <tt class="docutils literal">True</tt>, it will match that
string, but will not match <tt class="docutils literal">1</tt> or <tt class="docutils literal">true</tt>.</li>
</ol>
</li>
<li><em>Save</em>.</li>
</ol>
<p>In that list view, you can sort rules by drag and drop.</p>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
<p>To use this module, you need to:</p>
<ol class="arabic simple">
<li>Follow steps in <strong>Configuration</strong> section above.</li>
<li>Go to any list view.</li>
<li>Press <em>Import</em> and follow the import procedure as usual.</li>
</ol>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#id3">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>Add a setting to throw an error when multiple matches are found, instead of
falling back to creation of new record.</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-backend/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/server-backend/issues/new?body=module:%20base_import_match%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id5">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id6">Authors</a></h2>
<ul class="simple">
<li>Tecnativa</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id7">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:
* Jairo Llopis
* Vicent Cubells
* Ernesto Tejeda</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-backend/tree/12.0/base_import_match">OCA/server-backend</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2016 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

View File

@@ -1,2 +1,2 @@
email,name
michel.fletcher@agrolait.example.com,Michel Fletcher Changed
floyd.steward34@example.com,Floyd Steward Changed
1 email name
2 michel.fletcher@agrolait.example.com floyd.steward34@example.com Michel Fletcher Changed Floyd Steward Changed

View File

@@ -1,2 +1,2 @@
function,name
Function Changed,Michel Fletcher
Function Changed,Floyd Steward
1 function name
2 Function Changed Michel Fletcher Floyd Steward

View File

@@ -1,2 +1,2 @@
name,is_company,parent_id/id,email
Michel Fletcher,False,base.res_partner_2,changed@agrolait.example.com
Floyd Steward,False,base.res_partner_2,floyd.steward34.changed@example.com
1 name is_company parent_id/id email
2 Michel Fletcher Floyd Steward False base.res_partner_2 changed@agrolait.example.com floyd.steward34.changed@example.com

View File

@@ -1,2 +1,2 @@
name,vat,is_company
Agrolait Changed,BE0477472701,True
Deco Addict Changed,BE0477472701,True
1 name vat is_company
2 Agrolait Changed Deco Addict Changed BE0477472701 True

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2016 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@@ -28,34 +27,34 @@ class ImportCase(TransactionCase):
def test_res_partner_vat(self):
"""Change name based on VAT."""
agrolait = self.env.ref("base.res_partner_2")
agrolait.vat = "BE0477472701"
deco_addict = self.env.ref("base.res_partner_2")
deco_addict.vat = "BE0477472701"
record = self._base_import_record("res.partner", "res_partner_vat")
record.do(["name", "vat", "is_company"], OPTIONS)
agrolait.env.invalidate_all()
self.assertEqual(agrolait.name, "Agrolait Changed")
record.do(["name", "vat", "is_company"], [], OPTIONS)
deco_addict.env.cache.invalidate()
self.assertEqual(deco_addict.name, "Deco Addict Changed")
def test_res_partner_parent_name_is_company(self):
"""Change email based on parent_id, name and is_company."""
record = self._base_import_record(
"res.partner", "res_partner_parent_name_is_company")
record.do(["name", "is_company", "parent_id/id", "email"], OPTIONS)
record.do(["name", "is_company", "parent_id/id", "email"], [], OPTIONS)
self.assertEqual(
self.env.ref("base.res_partner_address_4").email,
"changed@agrolait.example.com")
"floyd.steward34.changed@example.com")
def test_res_partner_email(self):
"""Change name based on email."""
record = self._base_import_record("res.partner", "res_partner_email")
record.do(["email", "name"], OPTIONS)
record.do(["email", "name"], [], OPTIONS)
self.assertEqual(
self.env.ref("base.res_partner_address_4").name,
"Michel Fletcher Changed")
"Floyd Steward Changed")
def test_res_partner_name(self):
"""Change function based on name."""
record = self._base_import_record("res.partner", "res_partner_name")
record.do(["function", "name"], OPTIONS)
record.do(["function", "name"], [], OPTIONS)
self.assertEqual(
self.env.ref("base.res_partner_address_4").function,
"Function Changed")
@@ -63,7 +62,7 @@ class ImportCase(TransactionCase):
def test_res_users_login(self):
"""Change name based on login."""
record = self._base_import_record("res.users", "res_users_login")
record.do(["login", "name"], OPTIONS)
record.do(["login", "name"], [], OPTIONS)
self.assertEqual(
self.env.ref("base.user_demo").name,
"Demo User Changed")

View File

@@ -62,7 +62,7 @@
<field name="field_ids"/>
<separator/>
<group expand="0" string="Group By">
<filter string="Model" context="{'group_by': 'model_id'}"/>
<filter string="Model" context="{'group_by': 'model_id'}" name="model"/>
</group>
</search>
</field>