{% set nc = namespace(before_invoice_id=None) %} {%for l in record %} {% if nc.before_invoice_id != l.invoice.raw.id %}