You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
3.8 KiB

  1. .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
  2. :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
  3. :alt: License: AGPL-3
  4. =================
  5. Base Import Match
  6. =================
  7. By default, when importing data (like CSV import) with the ``base_import``
  8. module, Odoo follows this rule:
  9. - If you import the XMLID of a record, make an **update**.
  10. - If you do not, **create** a new record.
  11. This module allows you to set additional rules to match if a given import is an
  12. update or a new record.
  13. This is useful when you need to sync heterogeneous databases, and the field you
  14. use to match records in those databases with Odoo's is not the XMLID but the
  15. name, VAT, email, etc.
  16. After installing this module, the import logic will be changed to:
  17. - If you import the XMLID of a record, make an **update**.
  18. - If you do not:
  19. - If there are import match rules for the model you are importing:
  20. - Discard the rules that require fields you are not importing.
  21. - Traverse the remaining rules one by one in order to find a match in the database.
  22. - Skip the rule if it requires a special condition that is not
  23. satisfied.
  24. - If one match is found:
  25. - Stop traversing the rest of valid rules.
  26. - **Update** that record.
  27. - If zero or multiple matches are found:
  28. - Continue with the next rule.
  29. - If all rules are exhausted and no single match is found:
  30. - **Create** a new record.
  31. - If there are no match rules for your model:
  32. - **Create** a new record.
  33. By default 2 rules are installed for production instances:
  34. - One rule that will allow you to update companies based on their VAT, when
  35. ``is_company`` is ``True``.
  36. - One rule that will allow you to update users based on their login.
  37. In demo instances there are more examples.
  38. Configuration
  39. =============
  40. To configure this module, you need to:
  41. #. Go to *Settings > Technical > Database Structure > Import Match*.
  42. #. *Create*.
  43. #. Choose a *Model*.
  44. #. Choose the *Fields* that conform an unique key in that model.
  45. #. If the rule must be used only for certain imported values, check
  46. *Conditional* and enter the **exact string** that is going to be imported
  47. in *Imported value*.
  48. #. Keep in mind that the match here is evaluated as a case sensitive
  49. **text string** always. If you enter e.g. ``True``, it will match that
  50. string, but will not match ``1`` or ``true``.
  51. #. *Save*.
  52. In that list view, you can sort rules by drag and drop.
  53. Usage
  54. =====
  55. To use this module, you need to:
  56. #. Follow steps in **Configuration** section above.
  57. #. Go to any list view.
  58. #. Press *Import* and follow the import procedure as usual.
  59. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
  60. :alt: Try me on Runbot
  61. :target: https://runbot.odoo-community.org/runbot/149/9.0
  62. Known Issues / Roadmap
  63. ======================
  64. * Add a setting to throw an error when multiple matches are found, instead of
  65. falling back to creation of new record.
  66. Bug Tracker
  67. ===========
  68. Bugs are tracked on `GitHub Issues
  69. <https://github.com/OCA/server-tools/issues>`_. In case of trouble, please
  70. check there if your issue has already been reported. If you spotted it first,
  71. help us smashing it by providing a detailed and welcomed feedback.
  72. Credits
  73. =======
  74. Contributors
  75. ------------
  76. * Jairo Llopis <yajo.sk8@gmail.com>
  77. * Vicent Cubells <vicent.cubells@tecnativa.com>
  78. Maintainer
  79. ----------
  80. .. image:: https://odoo-community.org/logo.png
  81. :alt: Odoo Community Association
  82. :target: https://odoo-community.org
  83. This module is maintained by the OCA.
  84. OCA, or the Odoo Community Association, is a nonprofit organization whose
  85. mission is to support the collaborative development of Odoo features and
  86. promote its widespread use.
  87. To contribute to this module, please visit https://odoo-community.org.