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.

34 lines
1.2 KiB

  1. # Copyright 2017 - Today Coop IT Easy SCRLfs (<http://www.coopiteasy.be>)
  2. # - Rémy Taymans <remy@coopiteasy.be>
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  4. from odoo.addons.portal.controllers.portal import CustomerPortal
  5. class BeesdooAccountWebsiteController(CustomerPortal):
  6. # override from `portal` module
  7. CustomerPortal.MANDATORY_BILLING_FIELDS = [
  8. "city",
  9. "country_id",
  10. "phone",
  11. "street",
  12. "zipcode",
  13. ]
  14. CustomerPortal.OPTIONAL_BILLING_FIELDS = ["state_id"]
  15. def details_form_validate(self, data):
  16. error, error_message = super().details_form_validate(data)
  17. # since we override mandatory and optional billing fields,
  18. # parent method will insert the following key/value in `error` dict and `error_message` list,
  19. # preventing from saving the form. Workaround is to clear both dict and list.
  20. if (
  21. error.get("common")
  22. and error["common"] == "Unknown field"
  23. and "Unknown field 'name,email,company_name,vat'" in error_message
  24. ):
  25. error.pop("common")
  26. error_message.remove("Unknown field 'name,email,company_name,vat'")
  27. return error, error_message