Skip to content

Commit 0370999

Browse files
authored
Merge pull request #383 from OCA/17.0
Syncing from upstream OCA/server-backend (17.0)
2 parents 35fd8f6 + aa2ba6c commit 0370999

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+13281
-31
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ addon | version | maintainers | summary
2424
[base_external_dbsource](base_external_dbsource/) | 17.0.1.0.0 | | External Database Sources
2525
[base_external_dbsource_sqlite](base_external_dbsource_sqlite/) | 17.0.1.0.0 | [![anddago78](https://github.com/anddago78.png?size=30px)](https://github.com/anddago78) | External Database Source - SQLite
2626
[base_global_discount](base_global_discount/) | 17.0.1.0.0 | | Base Global Discount
27+
[base_import_match](base_import_match/) | 17.0.1.0.0 | | Try to avoid duplicates before importing
2728
[base_user_role](base_user_role/) | 17.0.1.1.2 | [![sebalix](https://github.com/sebalix.png?size=30px)](https://github.com/sebalix) [![jcdrubay](https://github.com/jcdrubay.png?size=30px)](https://github.com/jcdrubay) [![novawish](https://github.com/novawish.png?size=30px)](https://github.com/novawish) | User roles
28-
[base_user_role_company](base_user_role_company/) | 17.0.1.1.1 | | User roles by company
29+
[base_user_role_company](base_user_role_company/) | 17.0.1.2.0 | | User roles by company
2930
[base_user_role_history](base_user_role_history/) | 17.0.1.0.0 | [![ThomasBinsfeld](https://github.com/ThomasBinsfeld.png?size=30px)](https://github.com/ThomasBinsfeld) | This module allows to track the changes on users roles.
3031
[server_action_navigate](server_action_navigate/) | 17.0.1.0.0 | [![legalsylvain](https://github.com/legalsylvain.png?size=30px)](https://github.com/legalsylvain) [![ashishhirpara](https://github.com/ashishhirpara.png?size=30px)](https://github.com/ashishhirpara) | Navigate between any items of any Odoo Models
3132

base_import_match/README.rst

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
=================
2+
Base Import Match
3+
=================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:e2cf90a886e2e861e54a6fdd338f136042bf39b0b5af8ed31ea994ac39f3cfa7
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github
20+
:target: https://github.com/OCA/server-backend/tree/17.0/base_import_match
21+
:alt: OCA/server-backend
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/server-backend-17-0/server-backend-17-0-base_import_match
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-backend&target_branch=17.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
By default, when importing data (like CSV import) with the
32+
``base_import`` module, Odoo follows this rule:
33+
34+
- If you import the XMLID of a record, make an **update**.
35+
- If you do not, **create** a new record.
36+
37+
This module allows you to set additional rules to match if a given
38+
import is an update or a new record.
39+
40+
This is useful when you need to sync heterogeneous databases, and the
41+
field you use to match records in those databases with Odoo's is not the
42+
XMLID but the name, VAT, email, etc.
43+
44+
After installing this module, the import logic will be changed to:
45+
46+
- If you import the XMLID of a record, make an **update**.
47+
- If you do not:
48+
49+
- If there are import match rules for the model you are importing:
50+
51+
- Discard the rules that require fields you are not importing.
52+
- Traverse the remaining rules one by one in order to find a match
53+
in the database.
54+
55+
- Skip the rule if it requires a special condition that is not
56+
satisfied.
57+
- If one match is found:
58+
59+
- Stop traversing the rest of valid rules.
60+
- **Update** that record.
61+
62+
- If zero or multiple matches are found:
63+
64+
- Continue with the next rule.
65+
66+
- If all rules are exhausted and no single match is found:
67+
68+
- **Create** a new record.
69+
70+
- If there are no match rules for your model:
71+
72+
- **Create** a new record.
73+
74+
By default 2 rules are installed for production instances:
75+
76+
- One rule that will allow you to update companies based on their VAT,
77+
when ``is_company`` is ``True``.
78+
- One rule that will allow you to update users based on their login.
79+
80+
In demo instances there are more examples.
81+
82+
**Table of contents**
83+
84+
.. contents::
85+
:local:
86+
87+
Configuration
88+
=============
89+
90+
To configure this module, you need to:
91+
92+
1. Go to *Settings > Technical > Database Structure > Import Match*.
93+
2. *Create*.
94+
3. Choose a *Model*.
95+
4. Choose the *Fields* that conform a unique key in that model.
96+
5. If the rule must be used only for certain imported values, check
97+
*Conditional* and enter the **exact string** that is going to be
98+
imported in *Imported value*.
99+
100+
1. Keep in mind that the match here is evaluated as a case sensitive
101+
**text string** always. If you enter e.g. ``True``, it will match
102+
that string, but will not match ``1`` or ``true``.
103+
104+
6. *Save*.
105+
106+
In that list view, you can sort rules by drag and drop.
107+
108+
Usage
109+
=====
110+
111+
To use this module, you need to:
112+
113+
1. Follow steps in **Configuration** section above.
114+
2. Go to any list view.
115+
3. Press *Import* and follow the import procedure as usual.
116+
117+
Known issues / Roadmap
118+
======================
119+
120+
- Add a setting to throw an error when multiple matches are found,
121+
instead of falling back to creation of new record.
122+
123+
Bug Tracker
124+
===========
125+
126+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-backend/issues>`_.
127+
In case of trouble, please check there if your issue has already been reported.
128+
If you spotted it first, help us to smash it by providing a detailed and welcomed
129+
`feedback <https://github.com/OCA/server-backend/issues/new?body=module:%20base_import_match%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
130+
131+
Do not contact contributors directly about support or help with technical issues.
132+
133+
Credits
134+
=======
135+
136+
Authors
137+
-------
138+
139+
* Tecnativa
140+
141+
Contributors
142+
------------
143+
144+
- `Tecnativa <https://www.tecnativa.com>`__:
145+
146+
- Jairo Llopis
147+
- Vicent Cubells
148+
- Ernesto Tejeda
149+
150+
Maintainers
151+
-----------
152+
153+
This module is maintained by the OCA.
154+
155+
.. image:: https://odoo-community.org/logo.png
156+
:alt: Odoo Community Association
157+
:target: https://odoo-community.org
158+
159+
OCA, or the Odoo Community Association, is a nonprofit organization whose
160+
mission is to support the collaborative development of Odoo features and
161+
promote its widespread use.
162+
163+
This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/17.0/base_import_match>`_ project on GitHub.
164+
165+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

base_import_match/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
2+
# Copyright 2016 Tecnativa - Vicent Cubells
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
from . import models

base_import_match/__manifest__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
2+
# Copyright 2016 Tecnativa - Vicent Cubells
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
{
5+
"name": "Base Import Match",
6+
"summary": "Try to avoid duplicates before importing",
7+
"version": "17.0.1.0.0",
8+
"category": "Tools",
9+
"website": "https://github.com/OCA/server-backend",
10+
"author": "Tecnativa, " "Odoo Community Association (OCA)",
11+
"license": "AGPL-3",
12+
"application": False,
13+
"installable": True,
14+
"depends": ["base_import"],
15+
"data": [
16+
"security/ir.model.access.csv",
17+
"data/base_import_match.xml",
18+
"views/base_import_match_view.xml",
19+
],
20+
"demo": ["demo/base_import_match.xml"],
21+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!-- Copyright 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
3+
Copyright 2016 Tecnativa - Vicent Cubells
4+
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
5+
<odoo noupdate="1">
6+
<!-- Match partners by VAT when is_company is True -->
7+
<record model="base_import.match" id="res_partner_vat">
8+
<field name="model_id" eval="ref('base.model_res_partner')" />
9+
<field name="sequence" type="int">10</field>
10+
</record>
11+
<record model="base_import.match.field" id="res_partner_vat_vat">
12+
<field name="match_id" ref="base_import_match.res_partner_vat" />
13+
<field name="field_id" ref="base.field_res_partner__vat" />
14+
</record>
15+
<record model="base_import.match.field" id="res_partner_vat_is_company">
16+
<field name="match_id" ref="base_import_match.res_partner_vat" />
17+
<field name="field_id" ref="base.field_res_partner__is_company" />
18+
<field name="conditional">True</field>
19+
<field name="imported_value">True</field>
20+
</record>
21+
<!-- Match users by login -->
22+
<record model="base_import.match" id="res_users_login">
23+
<field name="model_id" eval="ref('base.model_res_users')" />
24+
<field name="sequence" type="int">50</field>
25+
</record>
26+
<record model="base_import.match.field" id="res_users_login_login">
27+
<field name="match_id" ref="base_import_match.res_users_login" />
28+
<field name="field_id" ref="base.field_res_users__login" />
29+
</record>
30+
</odoo>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!-- Copyright 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
3+
Copyright 2016 Tecnativa - Vicent Cubells
4+
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
5+
<odoo noupdate="1">
6+
<!-- Match partners by name, parent_id and is_company -->
7+
<record model="base_import.match" id="res_partner_parent_name_is_company">
8+
<field name="model_id" eval="ref('base.model_res_partner')" />
9+
<field name="sequence" type="int">20</field>
10+
</record>
11+
<record
12+
model="base_import.match.field"
13+
id="res_partner_parent_name_is_company_name"
14+
>
15+
<field name="match_id" ref="res_partner_parent_name_is_company" />
16+
<field name="field_id" ref="base.field_res_partner__name" />
17+
</record>
18+
<record
19+
model="base_import.match.field"
20+
id="res_partner_parent_name_is_company_parent"
21+
>
22+
<field name="match_id" ref="res_partner_parent_name_is_company" />
23+
<field name="field_id" ref="base.field_res_partner__parent_id" />
24+
</record>
25+
<record
26+
model="base_import.match.field"
27+
id="res_partner_parent_name_is_company_is_company"
28+
>
29+
<field name="match_id" ref="res_partner_parent_name_is_company" />
30+
<field name="field_id" ref="base.field_res_partner__is_company" />
31+
</record>
32+
<!-- Match partner by email -->
33+
<record model="base_import.match" id="res_partner_email">
34+
<field name="model_id" eval="ref('base.model_res_partner')" />
35+
<field name="sequence" type="int">30</field>
36+
</record>
37+
<record model="base_import.match.field" id="res_partner_email_email">
38+
<field name="match_id" ref="base_import_match.res_partner_email" />
39+
<field name="field_id" ref="base.field_res_partner__email" />
40+
</record>
41+
<!-- Match partner by name -->
42+
<record model="base_import.match" id="res_partner_name">
43+
<field name="model_id" eval="ref('base.model_res_partner')" />
44+
<field name="sequence" type="int">40</field>
45+
</record>
46+
<record model="base_import.match.field" id="res_partner_name_name">
47+
<field name="match_id" ref="base_import_match.res_partner_name" />
48+
<field name="field_id" ref="base.field_res_partner__name" />
49+
</record>
50+
</odoo>

0 commit comments

Comments
 (0)