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.

63 lines
1.9 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. # todo consistency: S_SR_GET, S_SR_RETURN_GET, S_SR_POST ...
  14. S_SUBSCRIPTION_REQUEST_BASE = {
  15. "name": {"type": "string", "required": True, "empty": False},
  16. "email": {"type": "string", "required": True, "empty": False},
  17. "ordered_parts": {"type": "integer", "required": True},
  18. "address": {
  19. "type": "dict",
  20. "schema": {
  21. "street": {"type": "string", "required": True, "empty": False},
  22. "zip_code": {"type": "string", "required": True, "empty": False},
  23. "city": {"type": "string", "required": True, "empty": False},
  24. "country": {"type": "string", "required": True, "empty": False},
  25. },
  26. },
  27. "lang": {"type": "string", "required": True, "empty": False},
  28. }
  29. S_SUBSCRIPTION_REQUEST_GET = {
  30. **S_SUBSCRIPTION_REQUEST_BASE,
  31. **{
  32. "id": {"type": "integer", "required": True},
  33. "date": {"type": "string", "required": True, "empty": False},
  34. "share_product": {
  35. "type": "dict",
  36. "schema": {
  37. "id": {"type": "integer", "required": True},
  38. "name": {"type": "string", "required": True, "empty": False},
  39. },
  40. },
  41. },
  42. }
  43. S_SUBSCRIPTION_REQUEST_CREATE = {
  44. **S_SUBSCRIPTION_REQUEST_BASE,
  45. **{"share_product": {"type": "integer", "required": True}},
  46. }
  47. S_SUBSCRIPTION_REQUEST_LIST = {
  48. "count": {"type": "integer", "required": True},
  49. "rows": {
  50. "type": "list",
  51. "schema": {"type": "dict", "schema": S_SUBSCRIPTION_REQUEST_GET},
  52. },
  53. }