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.

160 lines
5.3 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:
  10. return error(
  11. field, _("{} does not match format '%Y-%m-%d'".format(value))
  12. )
  13. S_MANY_2_ONE = {
  14. "type": "dict",
  15. "schema": {
  16. "id": {"type": "integer", "required": True},
  17. "name": {"type": "string", "required": True, "empty": False},
  18. },
  19. }
  20. S_SUBSCRIPTION_REQUEST_GET = {"_id": {"type": "integer"}}
  21. S_SUBSCRIPTION_REQUEST_RETURN_GET = {
  22. "id": {"type": "integer", "required": True},
  23. "email": {"type": "string", "required": True, "empty": False},
  24. "name": {"type": "string", "required": True, "empty": False},
  25. "date": {"type": "string", "required": True, "empty": False},
  26. "state": {"type": "string", "required": True, "empty": False},
  27. "ordered_parts": {"type": "integer", "required": True},
  28. "share_product": S_MANY_2_ONE,
  29. "address": {
  30. "type": "dict",
  31. "schema": {
  32. "street": {"type": "string", "required": True, "empty": False},
  33. "zip_code": {"type": "string", "required": True, "empty": False},
  34. "city": {"type": "string", "required": True, "empty": False},
  35. "country": {"type": "string", "required": True, "empty": False},
  36. },
  37. },
  38. "lang": {"type": "string", "required": True, "empty": False},
  39. "capital_release_request": {
  40. "type": "list",
  41. "schema": {"type": "integer"},
  42. "required": True,
  43. "empty": True,
  44. },
  45. }
  46. S_SUBSCRIPTION_REQUEST_SEARCH = {
  47. "date_from": {"type": "string", "check_with": date_validator},
  48. "date_to": {"type": "string", "check_with": date_validator},
  49. }
  50. S_SUBSCRIPTION_REQUEST_RETURN_SEARCH = {
  51. "count": {"type": "integer", "required": True},
  52. "rows": {
  53. "type": "list",
  54. "schema": {
  55. "type": "dict",
  56. "schema": S_SUBSCRIPTION_REQUEST_RETURN_GET,
  57. },
  58. },
  59. }
  60. S_SUBSCRIPTION_REQUEST_CREATE = {
  61. "name": {"type": "string", "required": True, "empty": False},
  62. "email": {"type": "string", "required": True, "empty": False},
  63. "ordered_parts": {"type": "integer", "required": True},
  64. "share_product": {"type": "integer", "required": True},
  65. "address": {
  66. "type": "dict",
  67. "schema": {
  68. "street": {"type": "string", "required": True, "empty": False},
  69. "zip_code": {"type": "string", "required": True, "empty": False},
  70. "city": {"type": "string", "required": True, "empty": False},
  71. "country": {"type": "string", "required": True, "empty": False},
  72. },
  73. },
  74. "lang": {"type": "string", "required": True, "empty": False},
  75. }
  76. S_SUBSCRIPTION_REQUEST_UPDATE = {
  77. "name": {"type": "string"},
  78. "email": {"type": "string"},
  79. "ordered_parts": {"type": "integer"},
  80. "state": {"type": "string"},
  81. "address": {
  82. "type": "dict",
  83. "schema": {
  84. "street": {"type": "string"},
  85. "zip_code": {"type": "string"},
  86. "city": {"type": "string"},
  87. "country": {"type": "string"},
  88. },
  89. },
  90. "lang": {"type": "string"},
  91. "share_product": {"type": "integer"},
  92. }
  93. S_SUBSCRIPTION_REQUEST_VALIDATE = {"_id": {"type": "integer"}}
  94. S_INVOICE_GET = {"_id": {"type": "integer"}}
  95. S_INVOICE_LINE_RETURN_GET = {
  96. "type": "list",
  97. "schema": {
  98. "type": "dict",
  99. "schema": {
  100. "name": {"type": "string", "required": True},
  101. "account": S_MANY_2_ONE,
  102. "product": S_MANY_2_ONE,
  103. "quantity": {"type": "float", "required": True},
  104. "price_unit": {"type": "float", "required": True},
  105. },
  106. },
  107. "required": True,
  108. "empty": True,
  109. }
  110. S_INVOICE_RETURN_GET = {
  111. "id": {"type": "integer", "required": True},
  112. "name": {"type": "string", "required": True, "empty": False},
  113. "state": {"type": "string", "required": True, "empty": False},
  114. "type": {"type": "string", "required": True, "empty": False},
  115. "date": {"type": "string", "required": True, "empty": False},
  116. "date_due": {"type": "string", "required": True, "empty": False},
  117. "date_invoice": {"type": "string", "required": True, "empty": False},
  118. "partner": S_MANY_2_ONE,
  119. "journal": S_MANY_2_ONE,
  120. "account": S_MANY_2_ONE,
  121. "subscription_request": {
  122. "type": "dict",
  123. "schema": {"id": {"type": "integer"}, "name": {"type": "string"}},
  124. },
  125. "invoice_lines": S_INVOICE_LINE_RETURN_GET,
  126. }
  127. S_PAYMENT_RETURN_GET = {
  128. "id": {"type": "integer", "required": True},
  129. "journal": S_MANY_2_ONE,
  130. "invoice": S_MANY_2_ONE,
  131. "payment_date": {"type": "string", "check_with": date_validator},
  132. "amount": {"type": "float", "required": True},
  133. "communication": {"type": "string", "required": True},
  134. }
  135. S_PAYMENT_CREATE = {
  136. "journal": {"type": "integer", "required": True},
  137. "invoice": {"type": "integer", "required": True},
  138. "payment_date": {"type": "string", "check_with": date_validator},
  139. "amount": {"type": "float", "required": True},
  140. "communication": {"type": "string", "required": True},
  141. "payment_type": {"type": "string", "required": True},
  142. "payment_method": {"type": "string", "required": True},
  143. }