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.

156 lines
5.2 KiB

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