Skip to Content
Menu
This question has been flagged
2 Replies
4074 Rodiniai
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!")


Portretas
Atmesti
Autorius Best Answer

@Zbik dont work!


Portretas
Atmesti

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

Autorius

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:

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
1
birž. 19
3331
0
birž. 20
4058
1
geg. 19
3718
2
liep. 24
14222
1
liep. 21
8393