Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1932 Lượt xem

Hi, 
I am using Odoo 17 and have integrated Odoo into my Laravel Website. I am able to get all the Inovices and relevent details, but some how I am not able to get the PDF file for the invoice. 

public function getPdfInvoice(Invoice $invoice, $entityID) { // Authenticate and setup headers $this->setHeaders($entityID);

// Get the reference ID for the invoice $invoice_id = $invoice->reference_id;

// Determine the report type based on the invoice status if ($invoice->status == 1) { $report_name = 'account.report_invoice_with_payments'; // For paid invoices } else { $report_name = 'account.report_invoice'; // For unpaid invoices }

// Use the 'execute_report' method to generate the PDF $params = [ $this->encoder->encode($this->db), $this->encoder->encode($this->uid), $this->encoder->encode($this->password), $this->encoder->encode('report'), $this->encoder->encode('render_report'), $this->encoder->encode([$report_name, [$invoice_id]]) ];

$request = new Request('execute_kw', $params); $response = $this->models->send($request); Log::info("Odoo getPdfInvoice", ['response' => $response]);

// Check for errors in the response if ($response->faultCode()) { throw new \Exception('Error fetching PDF for invoice: ' . $response->faultString()); }

// Check if the response is valid and contains PDF data if (empty($response->value()->scalarval())) { throw new \Exception('Empty response, unable to fetch PDF'); }

// Decode the PDF binary data $pdfContent = base64_decode($response->value()->scalarval());

if (!$pdfContent) { throw new \Exception('Error fetching PDF for invoice: ' . $response->faultString()); } else { return $pdfContent; } }

I am always getting Object report doesn't exist

kindly check and help me out on this.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 25
439
1
thg 8 25
1309
1
thg 6 24
2207
0
thg 1 25
906
11
thg 10 24
29697