Created
November 7, 2024 13:52
-
-
Save pablohmontenegro/10eb41547405fc5abee5d62b0f660f8a to your computer and use it in GitHub Desktop.
overlap de fechas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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