Skip to content

Instantly share code, notes, and snippets.

@pablohmontenegro
Created November 7, 2024 13:52
Show Gist options
  • Save pablohmontenegro/10eb41547405fc5abee5d62b0f660f8a to your computer and use it in GitHub Desktop.
Save pablohmontenegro/10eb41547405fc5abee5d62b0f660f8a to your computer and use it in GitHub Desktop.
overlap de fechas
@api.constrains('tax_id', 'date_from', 'date_to')
def _check_date_overlap(self):
for record in self:
if record.date_from and record.date_to:
# Verificar que no haya superposición de fechas con otro registro
overlapping_records = self.search([
('tax_id', '=', record.tax_id.id),
('id', '!=', record.id), # Excluir el propio registro
('date_from', '<=', record.date_to),
('date_to', '>=', record.date_from)
])
if overlapping_records:
raise ValidationError("..")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment