Files
odoo_source/addons/account_edi/models/ir_actions_report.py
T
Benjamin Frantzen (bfr) 913f22f73f [ADD] account_edi: generic module to manage EDI (factur-x)
- account_edi is the base module to manage EDIs. It manages the generic worflow of import/export and defines the methods for import/export that should be overridden by each types of EDI (in different modules).
- On export, the files are added as attachment and can be embeded into pdf (format specific).
- On export, the exported format are set on the journal to allow different settings based on journal (different companies, countries, etc).
- On import, depending on the import method (from message_post or upload button in invoice tree view) a new invoice is created or an existing one is updated (only allowed draft invoices with no invoice lines).
- Adapted factur-x
2020-05-29 07:16:30 +00:00

17 lines
728 B
Python

# -*- coding: utf-8 -*-
from odoo import models, fields, api, _
class IrActionsReport(models.Model):
_inherit = 'ir.actions.report'
def _post_pdf(self, save_in_attachment, pdf_content=None, res_ids=None):
# OVERRIDE to embed some EDI documents inside the PDF.
if self.model == 'account.move' and res_ids and len(res_ids) == 1 and pdf_content:
invoice = self.env['account.move'].browse(res_ids)
if invoice.is_sale_document() and invoice.state != 'draft':
pdf_content = invoice.journal_id.edi_format_ids._embed_edis_to_pdf(pdf_content, invoice)
return super(IrActionsReport, self)._post_pdf(save_in_attachment, pdf_content=pdf_content, res_ids=res_ids)