Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
3642 Представления

It is a dating system, which has no coincidences with the day, the time and the doctor. I need to go through all the appointments. I have done this but it does not work for me.

class centromedico_citas(models.Model):  
    _name = 'centromedico.citas'

    fconsulta = fields.Date(string="Fecha consulta", required=True)
    hconsulta = fields.Float(string="Hora consulta", required=True)
    cdoctores = fields.Many2one('centromedico.medicos', string="Doctor/a", ondelete="cascade")

    @api.depends('fconsulta', 'hconsulta', 'cdoctores')
    def _citaunica(self):
        for C in self:
            if C.hconsulta == self.hconsulta and C.fconsulta== self.fconsulta and C.cdoctores == self.cdoctores:               
                  raise exceptions.ValidationError("El doctor ya tiene una cita a esa hora ese día!")
Аватар
Отменить
Лучший ответ

Here you are comparing two strings where odoo retrieves date or DateTime fields as a string. So here you are comparing str == str and results vary according to that. The solution is that you have to typecast the fields before comparison using pythons default or odoo's way. I can give you an example.

date = vals.get('date') # String
date = feilds.Date.from_string(date) # Date(01,02,2019) dateobject
Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
июн. 19
3987
1
июн. 19
3281
0
июн. 20
3984
2
июл. 24
14105
4
июн. 23
41826