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.

101 lines
3.7 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Daniel Reis
  5. # 2011
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. {
  22. 'name': 'Import data from SQL and ODBC data sources.',
  23. 'version': '1.3',
  24. 'category': 'Tools',
  25. 'description': """
  26. Import data directly from other databases.
  27. Installed in the Administration module, menu Configuration -> Import from SQL.
  28. Features:
  29. * Fetched data from the databases are used to build lines equivalent to
  30. regular import files. These are imported using the standard "import_data()"
  31. ORM method, benefiting from all its features, including xml_ids.
  32. * Each table import is defined by an SQL statement, used to build the
  33. equivalent for an import file. Each column's name should match the column
  34. names you would use in an import file. The first column must provide an
  35. unique identifier for the record, and will be used to build its xml_id.
  36. * SQL columns named "none" are ignored. This can be used for the first column
  37. of the SQL, so that it's used to build the XML Id but it's not imported to
  38. any OpenERP field.
  39. * The last sync date is the last successfull execution can be used in the SQL
  40. using "%(sync)s", or ":sync" in the case of Oracle.
  41. * When errors are found, only the record with the error fails import. The
  42. other correct records are commited. However, the "last sync date" will only
  43. be automaticaly updated when no errors are found.
  44. * The import execution can be scheduled to run automatically.
  45. Examples:
  46. * Importing suppliers to res.partner:
  47. SELECT distinct
  48. [SUPPLIER_CODE] as "ref"
  49. , [SUPPLIER_NAME] as "name"
  50. , 1 as "is_supplier"
  51. , [INFO] as "comment"
  52. FROM T_SUPPLIERS
  53. WHERE INACTIVE_DATE IS NULL and DATE_CHANGED >= %(sync)s
  54. * Importing products to product.product:
  55. SELECT PRODUCT_CODE as "ref"
  56. , PRODUCT_NAME as "name"
  57. , 'res_partner_id_'+SUPPLIER_ID as "partner_id/id"
  58. FROM T_PRODUCTS
  59. WHERE DATE_CHANGED >= %(sync)s
  60. Improvements ideas waiting for a contributor:
  61. * Allow to import many2one fields (currently not supported). Done by adding a
  62. second SQL sentence to get child record list?
  63. * Allow "import sets" that can be executed at different time intervals using
  64. different scheduler jobs.
  65. * Allow to inactivate/delete OpenERP records when not present in an SQL
  66. result set.
  67. Contributors
  68. ============
  69. * Maxime Chambreuil <maxime.chambreuil@savoirfairelinux.com>
  70. """,
  71. 'author': 'Daniel Reis',
  72. 'website': 'http://launchpad.net/addons-tko',
  73. 'images': [
  74. 'images/snapshot1.png',
  75. 'images/snapshot2.png',
  76. ],
  77. 'depends': [
  78. 'base',
  79. 'base_external_dbsource',
  80. ],
  81. 'data': [
  82. 'import_odbc_view.xml',
  83. 'security/ir.model.access.csv',
  84. ],
  85. 'demo': [
  86. 'import_odbc_demo.xml',
  87. ],
  88. 'test': [],
  89. 'installable': False,
  90. 'active': False,
  91. }
  92. # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: