Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
3981 Visualizzazioni
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
Abbandona
Autore Risposta migliore

@Zbik dont work!


Avatar
Abbandona

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

Autore

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")

Risposta migliore

Try this:

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

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
giu 19
3276
0
giu 20
3983
1
mag 19
3639
2
lug 24
14100
1
lug 21
8303