コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
5219 ビュー

Hello ,

I m facing an issue while printing report which is calling report of 

one model to other model,it is generating empty report when print via print menu

but when i do it from a custom button ( which i have created ) it is generating report.

 model_ids = link between two model

    @api.multi

    def report_print(self):

        self.ensure_one()

      return self.env['report'].get_action(self, 'model.report_name')

when i call this method by button click from model one 

model_ids.report_print() -->it is generating report


but when i print from print menu,i m getting blank report.

<report

            id="some_unique_id"

            string="Name"

            model="model.one"

            report_type="qweb-pdf"

            file="model_one.report_name_un"

            name="model_one.report_name_un"/>


<template id="report_name_un">

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

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

                    <t t-esc="doc.model_ids.report_print() "/>

                   

                </t>

            </t>

I have checked function it is calling ,but it is giving blank report when called from menu,whereas it is generating report when called from button.

アバター
破棄
最善の回答

Hi,

If you need to add it in the print menu itself, you need to write the parser file for the report, ie render_html function for the report,

class ReportInvoice(models.AbstractModel):
_name = 'report.test_module.report_invoice'

@api.multi
def render_html(self, docids, data=None):
docids = XYZ.invoice_ids.ids
docargs = {
'doc_ids': docids,
'doc_model': 'account.invoice',
'docs': self.env['account.invoice'].browse(docids),
'data': data,
}
return self.env['report'].render('account.report_invoice', docargs)


and from the above function you have to change the docids, doc_model and docs according to your need.


Thanks

アバター
破棄

Still, be aware that Multi is deprecated. So you can remove the line '@api.muliti'.

yes, for latest versions, the answer is from 2020

関連投稿 返信 ビュー 活動
0
4月 20
6
9
8月 23
20351
2
10月 18
3030
1
6月 17
4475
0
11月 16
6777