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

Hello ,i m trying to print account invoice report from sale order from print menu.

when i try to print it from custom button (print invoice) which i have made in sale order ,by linking sale order and invoice by invoice_ids ,i m getting Invoice report .

But when i try to print it from Print menu,empty report are generating.


Below is the method I'm calling.

    @api.multi

   def invoice_print(self):

        self.ensure_one()

        self.sent = True

        return self.env['report'].get_action(self, 'account.report_invoice')

when i m calling this method from my button it is generating report.


But when i m trying to call this method from print menu in Sale order by

<report

            id="some_unique_name"

            string=" Invoice"

            model="sale.order"

            report_type="qweb-pdf"

            file="module.report_sale_invoice"

            name="module.report_sale_invoice"/>



<template id="report_sale_invoice">

        <t t-call="report.html_container">

            <t t-foreach="docs" t-as="doc">

               <t t-esc="doc.invoice_ids.invoice_print()"/>  

            </t>

        </t>

    </template>

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

The issue you're facing seems to be related to how you're calling the invoice_print() method from the print menu in the sale order. Instead of directly calling the method in the template, you should use the report_invoice action to generate the report.

In XML:

<report


    id="some_unique_name"


    string="Invoice"


    model="sale.order"


    report_type="qweb-pdf"


    name="module.report_sale_invoice"


    file="module.report_sale_invoice"/>




In Python

@api.multi
def invoice_print(self):
self.ensure_one()
self.sent = True
report_action = self.env.ref('account.action_report_invoice')
return report_action.report_action(self)

You may successfully generate the invoice report by utilising the report_action method from the report action. The existing report action for the invoice report defined in the account module is retrieved using the env.ref('account.action_report_invoice') line.

Regards

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

inherit invoice full pdf template and it will works.

Ả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
964
1
thg 8 25
1645
1
thg 9 24
2428
1
thg 6 24
2619
0
thg 9 21
2759