point_of_sale: tolerate empty receipts in reports, pass the tests

bzr revid: p_christ@hol.gr-20101227085504-er2n08ppgga9qpcg
This commit is contained in:
P. Christeas
2010-12-27 10:55:04 +02:00
parent cdd21ff45a
commit aedda16fb9
2 changed files with 14 additions and 4 deletions
@@ -63,14 +63,19 @@ class order(report_sxw.rml_parse):
WHERE absl.pos_statement_id = %d"""%(order_id.id)
self.cr.execute(sql)
res = self.cr.fetchone()
lst.append(res[0])
if not res:
return ['', 0.0]
lst.append(res[0]) # todo: improve
sql2 = """ select sum(absl.amount) as amt from account_bank_statement as abs
LEFT JOIN account_bank_statement_line as absl ON abs.id = absl.statement_id
LEFT JOIN account_journal as aj ON aj.id = abs.journal_id
where aj.name = '%s' """%(res[0])
self.cr.execute(sql2)
res1 = self.cr.fetchone()
lst.append(res1[0])
if res1:
lst.append(res1[0])
else:
lst.append(0.0)
return lst
report_sxw.report_sxw('report.pos.receipt.with.remboursment', 'pos.order', 'addons/point_of_sale/report/pos_receipt_with_remboursment.rml', parser=order, header=False)
@@ -63,14 +63,19 @@ class order(report_sxw.rml_parse):
WHERE absl.pos_statement_id = %d"""%(order_id.id)
self.cr.execute(sql)
res = self.cr.fetchone()
lst.append(res[0])
if not res:
return ['', 0.0]
lst.append(res[0]) # todo: improve
sql2 = """ select sum(absl.amount) as amt from account_bank_statement as abs
LEFT JOIN account_bank_statement_line as absl ON abs.id = absl.statement_id
LEFT JOIN account_journal as aj ON aj.id = abs.journal_id
where aj.name = '%s' """%(res[0])
self.cr.execute(sql2)
res1 = self.cr.fetchone()
lst.append(res1[0])
if res1:
lst.append(res1[0])
else:
lst.append(0.0)
return lst
report_sxw.report_sxw('report.pos.receipt.without.remboursment', 'pos.order', 'addons/point_of_sale/report/pos_receipt_without_remboursment.rml', parser=order, header=False)