def METHOD_NAME(self):
    # Based in l10n_es_aeat module
    for record in self:
        domain = [
            ("id", "!=", record.id),
            ("tbai_tax_agency_id", "=", record.tbai_tax_agency_id.id),
        ]
        if record.date_from and record.date_to:
            domain += [
                "|",
                "&",
                ("date_from", "<=", record.date_to),
                ("date_from", ">=", record.date_from),
                "|",
                "&",
                ("date_to", "<=", record.date_to),
                ("date_to", ">=", record.date_from),
                "|",
                "&",
                ("date_from", "=", False),
                ("date_to", ">=", record.date_from),
                "&",
                ("date_to", "=", False),
                ("date_from", "<=", record.date_to),
            ]
        elif record.date_from:
            domain += [("date_to", ">=", record.date_from)]
        elif record.date_to:
            domain += [("date_from", "<=", record.date_to)]
        date_lst = record.search(domain)
        if date_lst:
            raise exceptions.ValidationError(
                _(
                    "TicketBAI Tax Agency %(agency)s:\n"
                    "Version %(version)s dates of the record "
                    "overlap with an existing record."
                )
                % {
                    "agency": record.tbai_tax_agency_id.name,
                    "version": record.version,
                }
            )