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 1, 2023
1 parent 728627e commit 6fe1b90
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 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,13 @@ 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)

@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 6fe1b90

Please sign in to comment.