diff --git a/aeat.py b/aeat.py index 58a00e9..885072d 100644 --- a/aeat.py +++ b/aeat.py @@ -1351,16 +1351,19 @@ class SIIReportLine(ModelSQL, ModelView): report2.operation_type, with_=[subquery])) - def compose_key(state, type): + def compose_key(sii_state, sii_type): return ( - ('sii_state', state), - ('sii_communication_type', type), + ('sii_state', sii_state), + ('sii_communication_type', sii_type), ) for invoice_id, sii_state, operation_type in cursor.fetchall(): invoice = invoiceid2record.pop(invoice_id) key = compose_key(sii_state, operation_type) - changes.setdefault(key, []).append(invoice) + for key_, value in key: + if getattr(invoice, key_, None) != value: + changes.setdefault(key, []).append(invoice) + break if invoiceid2record: changes[compose_key(None, None)] = list( invoiceid2record.values())