跳至内容
菜单
此问题已终结
2 回复
2409 查看

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>

形象
丢弃
最佳答案

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

形象
丢弃
最佳答案

inherit invoice full pdf template and it will works.

形象
丢弃
相关帖文 回复 查看 活动
1
6月 25
1204
1
9月 24
1865
1
6月 24
2111
0
9月 21
2166
2
8月 20
5233