Skip to content

Commit

Permalink
port add pdf to v16
Browse files Browse the repository at this point in the history
  • Loading branch information
bguillot committed Feb 3, 2025
1 parent b9ddee8 commit c4ab9a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions account_invoice_inter_company/models/account_move.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import logging
import base64
import logging

from odoo import _, api, fields, models
from odoo.exceptions import AccessError, UserError
Expand Down Expand Up @@ -72,8 +72,8 @@ def action_post(self):
src_invoice.with_company(dest_company.id).with_context(
skip_check_amount_difference=True
)._inter_company_create_invoice(dest_company)
if src_invoice.move_type in ["out_invoice", "out_refund"]:
src_invoice._attach_original_pdf_report()
for invoice in self.filtered(lambda i: i.is_sale_document()):
invoice.sudo()._attach_original_pdf_report()
# set invoice ref on supplier invoice when the customer invoice is validated
# (case where the source invoice was the supplier one)
for invoice in self.filtered(
Expand All @@ -86,7 +86,8 @@ def _attach_original_pdf_report(self):
supplier_invoice = self.auto_invoice_id
if not supplier_invoice:
supplier_invoice = self.search([("auto_invoice_id", "=", self.id)], limit=1)
pdf = self.env.ref("account.account_invoices")._render_qweb_pdf([self.id])[0]
report = self.env.ref("account.account_invoices").with_company(self.company_id)
pdf = report._render_qweb_pdf(report.report_name, [self.id])[0]
self.env["ir.attachment"].create(
{
"name": self.name + ".pdf",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ def test_purchase_attachement_in_invoice(self):
)
self.assertEqual(len(bill_a_pdf), 1)
self.assertEqual(bill_a_pdf.name, invoice_company_b.name + ".pdf")
invoice_company_b.button_cancel()
invoice_company_b.action_post()

def _confirm_invoice_with_product(self):
# Confirm the invoice of company A
Expand Down

0 comments on commit c4ab9a5

Please sign in to comment.