Skip to content

Commit

Permalink
[FIX] account_ux: create binary field tto access invoice by API
Browse files Browse the repository at this point in the history
  • Loading branch information
augusto-weiss committed Jun 2, 2023
1 parent 728627e commit 0ee8291
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions account_ux/models/account_move.py
@@ -1,5 +1,6 @@
# flake8: noqa
import json
import base64
from odoo import models, api, fields, _
from odoo.exceptions import UserError

Expand All @@ -16,6 +17,18 @@ class AccountMove(models.Model):
)
other_currency = fields.Boolean(compute='_compute_other_currency')

invoice_binary = fields.Binary(compute='_compute_invoice_binary')

def _compute_invoice_binary(self):
for rec in self:
bin_data, __ = self.env['ir.actions.report']._render_qweb_pdf('account.account_invoices', rec.id)
rec.invoice_binary = base64.b64encode(bin_data)

def get_invoice_report(self):
self.ensure_one()
bin_data, __ = self.env['ir.actions.report']._render_qweb_pdf('account.account_invoices', self.id)
return bin_data, __

@api.depends('company_currency_id', 'currency_id')
def _compute_other_currency(self):
other_currency = self.filtered(lambda x: x.company_currency_id != x.currency_id)
Expand Down

0 comments on commit 0ee8291

Please sign in to comment.