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.

103 lines
3.4 KiB

  1. # Copyright 2020 Coop IT Easy SCRL fs
  2. # Robin Keunen <robin@coopiteasy.be>
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  4. from odoo import _
  5. from odoo.fields import Date
  6. def date_validator(field, value, error):
  7. try:
  8. Date.from_string(value)
  9. except ValueError as e:
  10. return error(
  11. field, _("{} does not match format '%Y-%m-%d'".format(value))
  12. )
  13. S_SUBSCRIPTION_REQUEST_GET = {"_id": {"type": "integer"}}
  14. S_SUBSCRIPTION_REQUEST_RETURN_GET = {
  15. "id": {"type": "integer", "required": True},
  16. "email": {"type": "string", "required": True, "empty": False},
  17. "name": {"type": "string", "required": True, "empty": False},
  18. "date": {"type": "string", "required": True, "empty": False},
  19. "state": {"type": "string", "required": True, "empty": False},
  20. "ordered_parts": {"type": "integer", "required": True},
  21. "share_product": {
  22. "type": "dict",
  23. "schema": {
  24. "id": {"type": "integer", "required": True},
  25. "name": {"type": "string", "required": True, "empty": False},
  26. },
  27. },
  28. "address": {
  29. "type": "dict",
  30. "schema": {
  31. "street": {"type": "string", "required": True, "empty": False},
  32. "zip_code": {"type": "string", "required": True, "empty": False},
  33. "city": {"type": "string", "required": True, "empty": False},
  34. "country": {"type": "string", "required": True, "empty": False},
  35. },
  36. },
  37. "lang": {"type": "string", "required": True, "empty": False},
  38. "capital_release_request": {
  39. "type": "list",
  40. "schema": {"type": "integer"},
  41. "required": True,
  42. "empty": True,
  43. },
  44. }
  45. S_SUBSCRIPTION_REQUEST_SEARCH = {
  46. "date_from": {"type": "string", "check_with": date_validator},
  47. "date_to": {"type": "string", "check_with": date_validator},
  48. }
  49. S_SUBSCRIPTION_REQUEST_RETURN_SEARCH = {
  50. "count": {"type": "integer", "required": True},
  51. "rows": {
  52. "type": "list",
  53. "schema": {
  54. "type": "dict",
  55. "schema": S_SUBSCRIPTION_REQUEST_RETURN_GET,
  56. },
  57. },
  58. }
  59. S_SUBSCRIPTION_REQUEST_CREATE = {
  60. "name": {"type": "string", "required": True, "empty": False},
  61. "email": {"type": "string", "required": True, "empty": False},
  62. "ordered_parts": {"type": "integer", "required": True},
  63. "share_product": {"type": "integer", "required": True},
  64. "address": {
  65. "type": "dict",
  66. "schema": {
  67. "street": {"type": "string", "required": True, "empty": False},
  68. "zip_code": {"type": "string", "required": True, "empty": False},
  69. "city": {"type": "string", "required": True, "empty": False},
  70. "country": {"type": "string", "required": True, "empty": False},
  71. },
  72. },
  73. "lang": {"type": "string", "required": True, "empty": False},
  74. }
  75. S_SUBSCRIPTION_REQUEST_UPDATE = {
  76. "name": {"type": "string"},
  77. "email": {"type": "string"},
  78. "ordered_parts": {"type": "integer"},
  79. "state": {"type": "string"},
  80. "address": {
  81. "type": "dict",
  82. "schema": {
  83. "street": {"type": "string"},
  84. "zip_code": {"type": "string"},
  85. "city": {"type": "string"},
  86. "country": {"type": "string"},
  87. },
  88. },
  89. "lang": {"type": "string"},
  90. "share_product": {"type": "integer"},
  91. }
  92. S_SUBSCRIPTION_REQUEST_VALIDATE = {"_id": {"type": "integer"}}