When the user is creating a new record in a model(for example creating a new contact) I want to check the uniqueness of a field value just at the moment the field is changed, not after finishing and saving the entire form.
Here is my sample code:
quotation_id = fields.Many2one(
comodel_name="sale.order",
string="Quotation ID",
required=True,
readonly=True
)
and this is my XML:
<field name="quotation_id"/>
I've defined a sql constraint as follow:
_sql_constraints = [
('quotation_id_uniq', 'UNIQUE (quotation_id)', 'This Quotation Number is asigned to a previous spot. Please choose another one.')
]
The user can enter an ID in the field.
I want to check this field just as it changes and inform the user if ID is selected before.
How can I do that?