IMP load invoices and not lost current lines

This commit is contained in:
Raimon Esteve 2017-06-29 17:44:06 +02:00
parent 0a616f8bdb
commit 08be2d9bb2
1 changed files with 10 additions and 8 deletions

18
aeat.py
View File

@ -438,9 +438,8 @@ class SIIReport(Workflow, ModelSQL, ModelView):
Invoice = pool.get('account.invoice')
ReportLine = pool.get('aeat.sii.report.lines')
to_create = []
for report in reports:
if report.lines:
continue
domain = [
('sii_book_key', '=', report.book),
('move.period', '=', report.period.id),
@ -455,12 +454,15 @@ class SIIReport(Workflow, ModelSQL, ModelView):
'AceptadoConErrores', 'AceptadaConErrores']))
_logger.debug('Searching invoices for SII report: %s', domain)
invoices = Invoice.search(domain)
report.lines = [
ReportLine(invoice=invoice, report=report)
for invoice in invoices
]
report.save()
for invoice in Invoice.search(domain):
to_create.append({
'report': report,
'invoice': invoice,
})
if to_create:
ReportLine.create(to_create)
def submit_issued_invoices(self):
pool = Pool()