Skip to Content
Menu
This question has been flagged
2 Replies
3136 Views
In a dating system I need the doctor to not have an appointment on the same day and at the same time. This is my code but it does not work!

    @ api.constrains ('fconsulta', 'hconsulta', 'cdoctores')
    def _citaunica (self):
        for record in self:
            if record.hconsulta in self and record.fconsulta in self and record.cdoctores in self:
                raise exceptions.UserError ("The date must be later than today!")


Avatar
Discard
Author Best Answer

@Zbik dont work!


Avatar
Discard

You have given too little data to help us get a good answer. For example what is the fields definition?

Author

oh sorry, this

_name = 'centromedico.citas'

fconsulta = fields.Date(string="Fecha consulta", required=True)

hconsulta = fields.Float(string="Hora consulta", required=True)

cpaciente = fields.Many2one('centromedico.pacientes', string="Paciente", ondelete="cascade")

cdoctores = fields.Many2one('centromedico.medicos', string="Doctor/a", ondelete="cascade")

chistorial = fields.Many2one('centromedico.historialclinico', string="Historial", ondelete="cascade")

Best Answer

Try this:

if record.hconsulta and record.fconsulta and record.cdoctores:

Avatar
Discard
Related Posts Replies Views Activity
1
Jun 19
2446
0
Jun 20
3244
1
May 19
2649
2
Jul 24
12607
1
Jul 21
6668