Odoo modules extending contacts / partners
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.

121 lines
2.8 KiB

  1. import logging
  2. from odoo.api import Environment, SUPERUSER_ID
  3. _logger = logging.getLogger(__name__)
  4. # def pre_init_hook(cr, registry):
  5. # env = Environment(cr, SUPERUSER_ID, {})
  6. # _logger.info("Pre init hook")
  7. def post_init_hook(cr, registry):
  8. # Source : https://en.wikipedia.org/wiki/Age_of_majority (2024-05-29)
  9. env = Environment(cr, SUPERUSER_ID, {})
  10. env["res.country"].search([("code", "in", ("ID", "YE"))]).write(
  11. {
  12. "majority_age": 15,
  13. }
  14. )
  15. env["res.country"].search([("code", "in", ("KH", "CU", "MM", "VN"))]).write(
  16. {
  17. "majority_age": 16,
  18. }
  19. )
  20. env["res.country"].search([("code", "in", ("KP", "TL"))]).write(
  21. {
  22. "majority_age": 17,
  23. }
  24. )
  25. env["res.country"].search([("code", "in", ("DZ", "KR"))]).write(
  26. {
  27. "majority_age": 19,
  28. }
  29. )
  30. env["res.country.state"].search(
  31. [
  32. "|",
  33. "&",
  34. ("country_id.code", "=", "CA"),
  35. (
  36. "code",
  37. "in",
  38. (
  39. "BC",
  40. "NB",
  41. "NL",
  42. "NS",
  43. "NT",
  44. "NU",
  45. "YT",
  46. ),
  47. ),
  48. "&",
  49. ("country_id.code", "=", "US"),
  50. (
  51. "code",
  52. "in",
  53. (
  54. "AL",
  55. "NE",
  56. ),
  57. ),
  58. ]
  59. ).write(
  60. {
  61. "majority_age": 19,
  62. "same_country_age": False,
  63. }
  64. )
  65. env["res.country"].search([("code", "in", ("NZ", "TH"))]).write(
  66. {
  67. "majority_age": 20,
  68. }
  69. )
  70. env["res.country"].search(
  71. [
  72. (
  73. "code",
  74. "in",
  75. (
  76. "CM",
  77. "TD",
  78. "CI",
  79. "SZ",
  80. "GA",
  81. "GD",
  82. "HN",
  83. "KW",
  84. "LS",
  85. "MG",
  86. "NI",
  87. "NE",
  88. "PR",
  89. "WS",
  90. "AE",
  91. "ZM",
  92. ),
  93. )
  94. ]
  95. ).write(
  96. {
  97. "majority_age": 21,
  98. }
  99. )
  100. env["res.country.state"].search(
  101. [
  102. ("country_id.code", "=", "US"),
  103. ("code", "=", "MS"),
  104. ]
  105. ).write(
  106. {
  107. "majority_age": 21,
  108. }
  109. )
  110. _logger.info("\n#####\nPost init hook for contacts majority passed...\n#####\n")
  111. # def uninstall_hook(cr, registry):
  112. # env = Environment(cr, SUPERUSER_ID, {})
  113. # _logger.info("Uninstall hook")