Repository
OCA/server-backend · module folder · Try on Runboat
Module version
1.0.0
Category
Tools
Folder size
0.48 MB
License
AGPL-3
Application
No
Auto-installable
No
Website
https://github.com/OCA/server-backend
Last tracking update
2026-08-07 08:43:03
Authors
Odoo Community Association (OCA), Tecnativa
Maintainers
Odoo Community Association (OCA), Tecnativa
Committers
Weblate, OCA-git-bot, oca-ci, Celina Devigili
Odoo dependencies
odoo/odoo:
- web
Python dependencies
None
System dependencies
None
Required by
None
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.

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.

Code Analysis

Views touched (3)
XML IDNameModelTypeStatus
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)

New fields (0)

No new fields.

Public methods (1)
  • load(self, fields, data)
    @api.model
    Try 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.

New fields (5)
  • field_ids One2many → base_import.match.field
    comodel_name='base_import.match.field' help='Fields that will define an unique key.' inverse_name='match_id' required=True string='Fields'
  • model_id Many2one → ir.model
    domain=[('transient', '=', False)] help='In this model you will apply the match.' ondelete='cascade' required=True args: 'ir.model', 'Model'
  • model_name Char
    index=True related='model_id.model' store=True string='Model name'
  • name Char
    compute='_compute_name' index=True store=True
  • sequence Integer
    index=True
Public methods (0)

No public methods.

New fields (6)
  • conditional Boolean
    help='Enable if you want to use this field only in some conditions.'
  • field_id Many2one → ir.model.fields
    comodel_name='ir.model.fields' domain="[('model_id', '=', model_id)]" help='Field that will be part of an unique key.' ondelete='cascade' required=True string='Field'
  • imported_value Char
    help="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_id Many2one → base_import.match
    comodel_name='base_import.match' ondelete='cascade' required=True string='Match'
  • model_id Many2one
    related='match_id.model_id'
  • name Char
    related='field_id.name'
Public methods (0)

No public methods.

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Status
Open migration PR — not merged yet for this version
CI status
green — ready to merge
Open since
55 days ago
Last activity
34 days ago
Repository
OCA/server-backend
Pull request
[19.0][MIG] base_import_match: Migration to 19.0 (#467)