تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
3989 أدوات العرض
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:

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يونيو 19
3282
0
يونيو 20
3985
1
مايو 19
3643
2
يوليو 24
14107
1
يوليو 21
8306