Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4046 Lượt xem
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!")


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

@Zbik dont work!


Ảnh đại diện
Huỷ bỏ

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

Tác giả

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

Câu trả lời hay nhất

Try this:

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 19
3312
0
thg 6 20
4030
1
thg 5 19
3693
2
thg 7 24
14169
1
thg 7 21
8371