我刚才在会计模块中创建了一个自定义报告 .. 效果很好 .. 现在我想做的是在标题中添加一个默认按钮,但这是与我的自定义报告相关
<report
id="account_invoices"
model="account.invoice"
string="Factura pre-impresa"
report_type="qweb-pdf"
name="custom_report_module.report_custom_template"
file="custom_report_module.report_custom_template"
attachment_use="True"
attachment="(object.state in ('open','paid')) and
('INV'+(object.number or '').replace('/','')+'.pdf')"
/>
这就是我所说的出现在下拉列表中的报告,之后我尝试添加按钮,但它对我不起作用
<record id="my_invoice_tree_inherit" model="ir.ui.view">
<field name="name">account.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<button name="invoice_print" position="after">
<button name="print_bank_statement" string="Print Statement" type="object" help="Print in Pdf"/>
</button>
</field>
</record>
一些帮助???
请您参考如下方法:
如果您查看其他带有在 Odoo v11 中打印某些报告的方法的按钮,它们看起来像这样:
@api.multi
def print_quotation(self):
self.filtered(lambda s: s.state == 'draft').write({'state': 'sent'})
return self.env.ref('sale.action_report_saleorder').report_action(self)
因此,在您的情况下,如果您不想运行任何 python 操作,您可以简化运行:
@api.multi
def print_bank_statement(self):
return self.env.ref('module_name.account_invoices').report_action(self)
此外,您可以直接调用报告的 XML ID,而无需像这样调用任何 python 代码:
<button name="%(account_invoices)d" string="Print" type="action" />
确保您在此处使用正确的按钮类型:type="action"
正如@Amal 所说,检查您继承的表单引用是否正确
