Base Import Match
base_import_match · OCA/server-backend
OCA/server-tools 8.0–10.0 → OCA/server-backend 11.0–18.0
-
Security25/25No findings
-
Activity12/25Last human commit 17 months ago
-
Required by5/250 modules depend on it
-
Maturity25/25In 11 Odoo series since 8.0
Heuristic over the facts below, not an audit · How it's computed
Description
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.
- If there are import match rules for the model you are importing:
By default 2 rules are installed for production instances:
- One rule that will allow you to update companies based on their VAT,
when
is_companyisTrue. - One rule that will allow you to update users based on their login.
In demo instances there are more examples.
Dependencies
- Odoo dependencies
- Python dependencies
- None
- System dependencies
- None
- Required by
- None
Code analysis
Extracted from the source by best-effort static analysis (no code is executed); details may be incomplete.
Views touched 3
| XML ID | Name | Model | Type | Status |
|---|---|---|---|---|
match_form_view |
Import match form view | base_import.match | form | New |
match_search_view |
Import match search view | base_import.match | search | New |
match_tree_view |
Import match list view | base_import.match | list | New |
HTTP endpoints 0
No HTTP endpoints found for this module.
Models touched 3
No new fields.
Public methods (1)-
load(self, fields, data)@api.modelTry to identify rows by other pseudo-unique keys. It searches for rows that have no XMLID specified, and gives them one if any :attr:`~.field_ids` combination is found. With a valid XMLID in place, Odoo will understand that it must *update* the record instead of *creating* a new one.
-
field_idsOne2many → base_import.match.fieldcomodel_name='base_import.match.field'help='Fields that will define an unique key.'inverse_name='match_id'required=Truestring='Fields' -
model_idMany2one → ir.modeldomain=[('transient', '=', False)]help='In this model you will apply the match.'ondelete='cascade'required=True args: 'ir.model', 'Model' -
model_nameCharindex=Truerelated='model_id.model'store=Truestring='Model name' -
nameCharcompute='_compute_name'index=Truestore=True -
sequenceIntegerindex=True
No public methods.
-
conditionalBooleanhelp='Enable if you want to use this field only in some conditions.' -
field_idMany2one → ir.model.fieldscomodel_name='ir.model.fields'domain="[('model_id', '=', model_id)]"help='Field that will be part of an unique key.'ondelete='cascade'required=Truestring='Field' -
imported_valueCharhelp="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'." -
match_idMany2one → base_import.matchcomodel_name='base_import.match'ondelete='cascade'required=Truestring='Match' -
model_idMany2onerelated='match_id.model_id' -
nameCharrelated='field_id.name'
No public methods.
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…
Loading…