fix invoice sii_state, take care only sended lines

This commit is contained in:
Àngel Àlvarez 2017-06-13 12:45:49 +02:00
parent 32f14eb8f2
commit 79868c6f66
1 changed files with 3 additions and 2 deletions

View File

@ -97,14 +97,15 @@ class Invoice:
table = SIILines.__table__()
cursor = Transaction().connection.cursor()
cursor.execute(*table.select(Max(table.id), table.invoice,
where=table.invoice.in_([x.id for x in invoices]),
where=(table.invoice.in_([x.id for x in invoices]) &
(table.state != None)),
group_by=table.invoice))
lines = [a[0] for a in cursor.fetchall()]
if lines:
cursor.execute(*table.select(table.state, table.invoice,
where=table.id.in_(lines)))
where=(table.id.in_(lines)) & (table.state != None)))
for state, inv in cursor.fetchall():
result['sii_state'][inv] = state