Website forms allow us to plug in our own validations and computations to form processing. This is done by implementing a website_form_input_filter() method with the logic on the target model. This method should expect a values argument, containing a dictionary, performing validations, and even modifying it, and then return the final values dictionary to be used.
We will make use of it to implement two features:
- Removing any leading and trailing spaces from the task title
- Ensuring that the task title is at least three characters long
Add the todo_website/models/todo_task.py file containing the following code:
from odoo import api, models from odoo.exceptions import ValidationError class TodoTask(models.Model): _inherit ...