Report 如何打印所有发票?奥多-10
我想打印属于特定客户的所有报告。 我已经有了自己的报告格式。 我不知道如何添加“打印所有”按钮来打印(或仅保存为pdf)所有发票 如果有人知道我在哪里可以找到类似的解决方案,请帮助。Report 如何打印所有发票?奥多-10,report,odoo,odoo-10,Report,Odoo,Odoo 10,我想打印属于特定客户的所有报告。 我已经有了自己的报告格式。 我不知道如何添加“打印所有”按钮来打印(或仅保存为pdf)所有发票 如果有人知道我在哪里可以找到类似的解决方案,请帮助。 如果我不够清楚或者您需要更多信息,请告诉我。无需编写自己的函数来打印与客户相关的所有报告,在客户表单下有智能按钮“发票”,这将打开特定于客户的发票,您可以按照@WaKo的回答进行打印。您可以在ListView中添加一个按钮,并使用JavaScript单独下载文件(调用python方法以获取base64字符串形式的报
如果我不够清楚或者您需要更多信息,请告诉我。无需编写自己的函数来打印与客户相关的所有报告,在客户表单下有智能按钮“发票”,这将打开特定于客户的发票,您可以按照@WaKo的回答进行打印。您可以在ListView中添加一个按钮,并使用JavaScript单独下载文件(调用python方法以获取base64字符串形式的报告数据) 要添加按钮,需要覆盖ListView Qweb模板 Qweb:
<?xml version="1.0" encoding="UTF-8"?>
<templates id="sync_template" xml:space="preserve">
<t t-extend="ListView.buttons">
<t t-jquery="button.oe_list_add" t-operation="after">
<t t-if="widget.model == 'account.invoice'">
<button class="btn btn-sm btn-default oe_print_all" type="button">Print All</button>
</t>
</t>
</t>
</templates>
}
我使用了get\u report\u data
方法,该方法返回元组列表[(发票数据,名称),…]
Python
class AccountInvoice(models.Model):
_inherit = "account.invoice"
@api.model
def get_report_data(self, ids):
report_obj = self.env['report']
return [(base64.b64encode(report_obj.get_pdf(invoice, "account.report_invoice")),
invoice.number.replace('/', '-') if invoice.number else '')
for invoice in self.browse(ids)]
在列表视图中选择所有发票,然后单击“打印”按钮。谢谢您的建议,但我必须单独打印所有发票。例如,如果用户“some_name”有55张发票,我需要55份pdf文档。谢谢你的建议,但我必须单独打印所有发票。例如,如果用户“some_name”有55张发票,我需要55份pdf文档。
class AccountInvoice(models.Model):
_inherit = "account.invoice"
@api.model
def get_report_data(self, ids):
report_obj = self.env['report']
return [(base64.b64encode(report_obj.get_pdf(invoice, "account.report_invoice")),
invoice.number.replace('/', '-') if invoice.number else '')
for invoice in self.browse(ids)]