If condition in a model (Error) - Odoo 11
I need to check that within my 'appointment' model does not coincide the time, the doctor and the day. That is, the 'appointments' do not coincide. I have done this but it does not work for me. Would someone know how to do it?
_name = 'centromedico.appointments'
datea = fields.Date(string="Fecha consulta", required=True)
timea = fields.Float(string="Hora consulta", required=True)
doctora = fields.Many2one('centromedico.medicos', string="Doctor/a", required=True, ondelete="cascade")
@api.depends('fconsulta', 'hconsulta', 'cdoctores')
for C in self:
if C.datea == centromedico.datea and C.timea == centromedico.timea and C.doctora == centromedico.doctora:
raise exceptions.ValidationError("This doctor already has an appointment at that time that day")