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.

83 lines
2.7KB

  1. # Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
  2. # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. import re
  5. from odoo_module_migrate.base_migration_script import BaseMigrationScript
  6. _TEXT_ERRORS = {
  7. "*": {
  8. "web_settings_dashboard":
  9. "[V13] Reference to 'web_settings_dashboard'"
  10. ". This module has been removed."
  11. },
  12. ".py": {
  13. r".*@api.returns.*\n":
  14. "[13] Use of deprecated decorator '@api.returns'",
  15. r".*@api.cr.*\n":
  16. "[13] Use of deprecated decorator '@api.cr'",
  17. r"@api.model_cr\b":
  18. "[13] Use of deprecated decorator '@api.model_cr'",
  19. r"@api.model_cr_context\b":
  20. "[13] Use of deprecated decorator '@api.model_cr_context'",
  21. },
  22. }
  23. _TEXT_REPLACES = {
  24. ".py": {
  25. r".*@api.one.*\n": "",
  26. r"\.sudo\((?P<user>[^/)]+?)\)": r".with_user(\g<user>)",
  27. r"\.suspend_security": ".sudo",
  28. r"\"base_suspend_security\",\n": "",
  29. r"\._find_partner_from_emails\(": "._mail_find_partner_from_emails(",
  30. r"\._search_on_partner\(": "._mail_search_on_partner(",
  31. r"\._search_on_user\(": "._mail_search_on_user(",
  32. r'\btrack_visibility="[^"]*"': "tracking=True",
  33. r"\btrack_visibility='[^']*'": "tracking=True",
  34. },
  35. ".xml": {
  36. r"( |\t)*<field name=('|\")view_type('|\")>.*</field>\n": "",
  37. r"src_model": "binding_model",
  38. re.compile(
  39. r"""
  40. # find a button...
  41. <button
  42. \s[^>]*
  43. # ... that is a oe_stat_button
  44. class=['"].*\b
  45. oe_stat_button
  46. \b.*['"]
  47. [^>]*>\s*
  48. # ... that contains a field
  49. <field\s+
  50. (
  51. [^>]*
  52. (
  53. # ... named "active"
  54. name=['"]active['"]|
  55. # ... with a boolean_button widget
  56. widget=['"]boolean_button['"]
  57. )
  58. [^>]*
  59. ){2}
  60. [^>]*>\s*
  61. </button>
  62. """,
  63. re.VERBOSE,
  64. ): """
  65. <field name="active" invisible="1" />
  66. <widget
  67. name="web_ribbon"
  68. title="Archived"
  69. bg_color="bg-danger"
  70. attrs="{'invisible': [('active', '=', True)]}"
  71. />
  72. """,
  73. },
  74. }
  75. class MigrationScript(BaseMigrationScript):
  76. _TEXT_ERRORS = _TEXT_ERRORS
  77. _TEXT_REPLACES = _TEXT_REPLACES
上海开阖软件有限公司 沪ICP备12045867号-1