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.

95 lines
3.1 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. }
  39. S_SUBSCRIPTION_REQUEST_SEARCH = {
  40. "date_from": {"type": "string", "check_with": date_validator},
  41. "date_to": {"type": "string", "check_with": date_validator},
  42. }
  43. S_SUBSCRIPTION_REQUEST_RETURN_SEARCH = {
  44. "count": {"type": "integer", "required": True},
  45. "rows": {
  46. "type": "list",
  47. "schema": {
  48. "type": "dict",
  49. "schema": S_SUBSCRIPTION_REQUEST_RETURN_GET,
  50. },
  51. },
  52. }
  53. S_SUBSCRIPTION_REQUEST_CREATE = {
  54. "name": {"type": "string", "required": True, "empty": False},
  55. "email": {"type": "string", "required": True, "empty": False},
  56. "ordered_parts": {"type": "integer", "required": True},
  57. "share_product": {"type": "integer", "required": True},
  58. "address": {
  59. "type": "dict",
  60. "schema": {
  61. "street": {"type": "string", "required": True, "empty": False},
  62. "zip_code": {"type": "string", "required": True, "empty": False},
  63. "city": {"type": "string", "required": True, "empty": False},
  64. "country": {"type": "string", "required": True, "empty": False},
  65. },
  66. },
  67. "lang": {"type": "string", "required": True, "empty": False},
  68. }
  69. S_SUBSCRIPTION_REQUEST_UPDATE = {
  70. "name": {"type": "string"},
  71. "email": {"type": "string"},
  72. "ordered_parts": {"type": "integer"},
  73. "state": {"type": "string"},
  74. "address": {
  75. "type": "dict",
  76. "schema": {
  77. "street": {"type": "string"},
  78. "zip_code": {"type": "string"},
  79. "city": {"type": "string"},
  80. "country": {"type": "string"},
  81. },
  82. },
  83. "lang": {"type": "string"},
  84. "share_product": {"type": "integer"},
  85. }