Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
3995 Переглядів
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!")


Аватар
Відмінити
Автор Найкраща відповідь

@Zbik dont work!


Аватар
Відмінити

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

Автор

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

Найкраща відповідь

Try this:

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

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
черв. 19
3288
0
черв. 20
3991
1
трав. 19
3648
2
лип. 24
14126
1
лип. 21
8322