swissqr_report.py 776 B

12345678910111213141516171819202122
  1. # -*- coding:utf-8 -*-
  2. from odoo import api, models
  3. class ReportSwissQR(models.AbstractModel):
  4. _name = 'report.l10n_ch.qr_report_main'
  5. _description = 'Swiss QR-bill report'
  6. @api.model
  7. def _get_report_values(self, docids, data=None):
  8. docs = self.env['account.move'].browse(docids)
  9. qr_code_urls = {}
  10. for invoice in docs:
  11. qr_code_urls[invoice.id] = invoice.partner_bank_id.build_qr_code_base64(invoice.amount_residual, invoice.ref or invoice.name, invoice.payment_reference, invoice.currency_id, invoice.partner_id, qr_method='ch_qr', silent_errors=False)
  12. return {
  13. 'doc_ids': docids,
  14. 'doc_model': 'account.move',
  15. 'docs': docs,
  16. 'qr_code_urls': qr_code_urls,
  17. }